简体   繁体   中英

Seach all types and all indexes in elasticsearch using NEST

Everybody, I use .net NEST library to query ElasticSearch. There is a problem on search operation. I want to search all documents in all types of all indexes.

How can I search all documents without determining document Type? and how can I convert retrieved results to Json or objects like this?

After investigations I found this code which helped me:

client.Search<dynamic>(s => s
      .AllIndices()
      .AllTypes()
      .Query(q => q
             .QueryString(qs => qs.Query(query)
      )));

which searchs on all indexes and all types. of course the other way is to use:

client.Raw.Search()

function and pass the every details of query in raw json format.

and for converting to json, best option is using JsonValue.Parse()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM