Search Multiple Indices using elastic low level client

I am trying to use elastic low level client to search multiple indices through -

client.LowLevel.Search<StringResponse>(PostData.Serializable(new SearchRequest(new[] {"Index1", "Index2"}) { Size = 10, From = 0, Query = searchQuery))

Results i am getting are across other indices as well which i have not defined in the list of indices to search.

I found a work around -

client.LowLevel.Search<StringResponse>("Index", PostData.Serializable(new SearchRequest() { Size = 10, From = 0, Query = searchQuery))

But this way i am not able to search multiple indices.

I also cant use the high level client since i want to return raw search response (without deserializing) which i have only been able to achieve through low level client.

@forloop Hi, can you please help me if there is a way to return raw json response from elastic high level client or a solution for the question above.

With the low level client call, the indices must be specified as the index parameter, comma separated. For example

var response = client.LowLevel.Search<StringResponse>(
    PostData.Serializable(new SearchRequest { 
        Size = 10, 
        From = 0, 
        Query = searchQuery

@forloop Thanks for helping out. The above solution worked.

Had another question related to the same. Is there a way to specify indices name with wildcard ? Like i want to search all indices which end with _qa (news_qa, person_qa, apps_qa). Is there something like *_qa which i can specify while specifying indices to search in low level client.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.