简体   繁体   English

使用Mpdreamz / NEST将查询作为字符串传递给elasticsearch

[英]Passing query as string to elasticsearch using Mpdreamz/NEST

I started using NEST and got it working. 我开始使用NEST并使其正常工作。 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")))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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