コード例 #1
0
        public async Task <StringResponse> Search(string name, string query)
        {
            var data = PostData.String(query);

            var searchAsync = await _client.SearchAsync <StringResponse>(name, data);

            return(searchAsync);
        }
コード例 #2
0
        public async Task <EsfQueryRunResult> RunQuery(string query)
        {
            var response = await _elasticClient.SearchAsync <string>(_indexName, _typeName, query);

            ThrowIfError(response);

            return(new EsfQueryRunResult
            {
                Result = response.Body
            });
        }
コード例 #3
0
        /// <summary>
        /// Gets counts of ElasticSearch document type grouping field, for a given query.
        /// </summary>
        /// <param name="query">The raw count query string.</param>
        /// <returns>An enumerable list of key/value pairs.</returns>
        public async Task <IEnumerable <DocumentCount> > GetCounts(string query)
        {
            var response = await _lowLevelClient.SearchAsync <string>(query);

            if (!response.Success)
            {
                throw new Exception($"Unable to execute search due to errors in query: {JsonConvert.SerializeObject(response.ServerError)}");
            }

            var oResponse = JObject.Parse(response.Body);
            var sBuckets  = JsonConvert.SerializeObject(oResponse.Last.First.First.First.Last.First);
            var buckets   = JsonConvert.DeserializeObject <List <DocumentCount> >(sBuckets);

            return(buckets);
        }