原文链接 : https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-named-queries-and-filters.html

    译文链接 : http://www.apache.wiki/pages/editpage.action?pageId=4883114

    贡献者 : ping

    每个过滤器和查询可以在其顶级定义中接受一个 _name。

    1. GET /_search
    2. {
    3. "query": {
    4. "bool" : {
    5. "should" : [
    6. {"match" : { "name.first" : {"query" : "shay", "_name" : "first"} }},
    7. {"match" : { "name.last" : {"query" : "banon", "_name" : "last"} }}
    8. ],
    9. "filter" : {
    10. "terms" : {
    11. "name.last" : ["banon", "kimchy"],
    12. "_name" : "test"
    13. }
    14. }
    15. }
    16. }
    17. }

    搜索响应将为每个匹配包括其匹配的 matched_queries。 查询和过滤器的标记仅对布尔查询有意义。