ElasticSearch NEST 查询 [英] ElasticSearch NEST Query
本文介绍了ElasticSearch NEST 查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 C# 中的 NEST 模拟我在 Sense(chrome 插件)中编写的查询.我无法弄清楚这两个查询之间的区别是什么.Sense 查询返回记录,而嵌套查询则不返回.查询如下:
I'm trying to mimic a query that I wrote in Sense (chrome plugin) using NEST in C#. I can't figure out what the difference between the two queries is. The Sense query returns records while the nest query does not. The queries are as follows:
var searchResults = client.Search<File>(s => s.Query(q => q.Term(p => p.fileContents, "int")));
和
{
"query": {
"term": {
"fileContents": {
"value": "int"
}
}
}
这两个查询有什么区别?为什么一个会返回记录而另一个不返回?
What is the difference between these two queries? Why would one return records and the other not?
推荐答案
您可以通过以下代码了解 NEST 使用的查询:
You can find out what query NEST uses with the following code:
var json = System.Text.Encoding.UTF8.GetString(searchResults.RequestInformation.Request);
然后你可以比较输出.
这篇关于ElasticSearch NEST 查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文