<1> title条件运作在根文档上

    <2> nested条件深入嵌套的comments栏位。它不会在存取根文档的栏位,或是其他嵌套文档的栏位。

    当然,一个nested查询可以匹配多个嵌套文档。
    每个文档的匹配会有各自的关联分数,但多个分数必须减少至单一分数才能应用至根文档。

    1. GET /my_index/blogpost/_search
    2. {
    3. "query": {
    4. "must": [
    5. { "match": { "title": "eggs" }},
    6. {
    7. "nested": {
    8. "path": "comments",
    9. "score_mode": "max", <1>
    10. "must": [
    11. { "match": { "comments.name": "john" }},
    12. { "match": { "comments.age": 28 }}
    13. ]
    14. }}}}
    15. }}}

    <1> 从最匹配的嵌套文档中给予根文档的_score值。

    nested过滤器类似於nested查询,除了无法使用score_mode参数。 只能使用在filter context—例如在filtered查询中—其作用类似其他的过滤器:
    包含或不包含,但不评分。