<1> title
条件运作在根文档上
<2> nested
条件深入
嵌套的comments
栏位。它不会在存取根文档的栏位,或是其他嵌套文档的栏位。
当然,一个nested
查询可以匹配多个嵌套文档。
每个文档的匹配会有各自的关联分数,但多个分数必须减少至单一分数才能应用至根文档。
GET /my_index/blogpost/_search
{
"query": {
"must": [
{ "match": { "title": "eggs" }},
{
"nested": {
"path": "comments",
"score_mode": "max", <1>
"must": [
{ "match": { "comments.name": "john" }},
{ "match": { "comments.age": 28 }}
]
}}}}
}}}
<1> 从最匹配的嵌套文档中给予根文档的_score
值。
nested
过滤器类似於nested
查询,除了无法使用score_mode
参数。 只能使用在filter context—例如在filtered
查询中—其作用类似其他的过滤器:
包含或不包含,但不评分。