I am trying to use elastic low level client to search multiple indices through -
client.LowLevel.Search(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("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.
As you can check Elastic nest client documentation you can pass a comma-separated list of index names to search.
TResponse Search<TResponse>(string index, PostData body, SearchRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
So your index string should be like "index1,index2".