我想通过查询只得到_source字段。但是它返回对我来说不必要的命中。那么如何在_source数据之前删除这些命中。
GET fms/user/_search?filter_path=hits.hits._source{"query": {"match_all": {}}}
答案 0 :(得分:0)
如果要过滤_source字段,则应考虑将已存在的_source参数与filter_path参数组合使用,如下所示:
POST /library/book?refresh
{"title": "Book #1", "rating": 200.1}
POST /library/book?refresh
{"title": "Book #2", "rating": 1.7}
POST /library/book?refresh
{"title": "Book #3", "rating": 0.1}
GET /_search?filter_path=hits.hits._source&_source=title&sort=rating:desc
{
"hits" : {
"hits" : [ {
"_source":{"title":"Book #1"}
}, {
"_source":{"title":"Book #2"}
}, {
"_source":{"title":"Book #3"}
} ]
}
}
有关详细信息,请访问https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html
由于您已经在使用filter_path,因此您只能获得源字段。