Is there a way not set the document type when doing search?


#1

What I'm trying to do now is I would like to search two document types in two indices. But in C#, Nest, you need you add a in the search function like this "Client.Search". Since there are different types when search this type on the other indices gives no result set. Is there a way to search in the following url?
http://ess01:9200/indexa,indexb/_search
Notice that no type is set. I tried to fire a query to the above endpoint and it works well. But I could not find a way to do it in C#. Any idea will be appreciated!


(Martijn Laarman) #2

client.Search<Document>(s=>s.Index("indexa,indexb")) will search both indices and map it to Document

.Index(Indices.Index("indexa", "indexb")) is a slightly longer version to do it.

Be sure to read https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/covariant-search-results.html

To understand how NEST can help searching multiple different json sources and map it to covariant list response.


#3

Thank you so much!


(system) #4

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