简体   繁体   中英

Passing query as string to elasticsearch using Mpdreamz/NEST

I started using NEST and got it working. I see that the query as string is depricated. Is there another way of doing this? lets say I want to search for "test" in the whole index.

Passing as string is indeed deprecated but will not be removed.

To search for a term over all indices use:

this.ConnectedClient.Search<MyDTO>(s=>s
    .AllIndices()
    .Query(q=>q.Term(f=>f.Name, ""))
);

Make sure to look at the test project and the documentation which have alot of example code.

如果您要查找的只是在所有字段中按单个单词搜索文档类型,则可以使用querystring查询类型。

Client.Search<T>(q=>q.Index("MyIndex").Query(q=>q.QueryString("test")))

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