yzl_66
会咏春拳的钢铁侠的爸
2019-01-22 15:30

C#使用Lamda表达式搜索ElasticSearch返回的数据为0,使用DSL就有返回条数

20
  • c#
  • elasticsearch

var node = new Uri("http://192.168.168.215:9200/");
var settings = new ConnectionSettings(node).DefaultIndex("stocknews");
var client = new ElasticClient(settings);
var searchResponse = client.Search(s => s
.Query(q => q
.Match(m => m
.Field(f => f.Summary)
.Query("LEO") ) ) );

var filter2 = new SearchRequest
{
Query = new MatchQuery
{
Field = "Summary",
Query = "LEO"
}
};
var searchResponse1 = client.Search(filter2);
同样的搜索条件,第二种DSL语法就有数据返回,第一种返回的Count为0

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答