private List <DocumentSearchResult <T> > Do(ElasticClient client, MultipleQuery <T> query, string path, JsonSerializerSettings jsonSettings, HttpMethod httpMethod, bool returnQueries) { var indexPattern = $"{client.TenantId}_*"; var response = client.Client.DoRequest <StringResponse>(httpMethod, $"{indexPattern}/{path}", query.ToJson()); CheckResponse(response); var responses = JsonConvert.DeserializeObject <MultipleDocumentSearchResult <T> >(response.Body, jsonSettings); var c = 0; var qs = query.ToArray(); responses.Resonses.ForEach(result => { result._Name = qs[c].Key; if (returnQueries) { result.Query = qs[c].Value; } c++; }); return(responses.Resonses); }
/// <summary> /// Multiple searches asynchronous. /// </summary> /// <param name="client">The client.</param> /// <param name="queries">The queries.</param> /// <param name="jsonSerializerSettings">The json serializer settings.</param> /// <param name="returnQueries">if set to <c>true</c> [return queries].</param> /// <returns>List of DocumentSearchResult of T</returns> public async Task <List <DocumentSearchResult <T> > > MultipleSearchAsync(ElasticClient client, MultipleQuery <T> queries, JsonSerializerSettings jsonSerializerSettings = null, bool returnQueries = false) { return(await DoAync(client, queries, Core.Const.Strings.MultiSearchPath, jsonSerializerSettings ?? JsonHelpers.CreateSerializerSettings(), HttpMethod.POST, returnQueries)); }