-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Description
Remove support for the scope field in facets and _scope field in the nested and parent/child queries. The scope support for nested queries will be replaced by the nested facet option and a facet filter with a nested filter. The nested filters will now support the a join option. Which controls whether to perform the block join. By default this enabled, but when disabled it returns the nested documents as hits instead of the joined root document.
Search request with the current scope support.
curl -s -XPOST 'localhost:9200/products/_search' -d '{
"query" : {
"nested" : {
"path" : "offers",
"query" : {
"match" : {
"offers.color" : "blue"
}
},
"_scope" : "my_scope"
}
},
"facets" : {
"size" : {
"terms" : {
"field" : "offers.size"
},
"scope" : "my_scope"
}
}
}'
The following will be functional equivalent of using the scope support:
curl -s -XPOST 'localhost:9200/products/_search?search_type=count' -d '{
"query" : {
"nested" : {
"path" : "offers",
"query" : {
"match" : {
"offers.color" : "blue"
}
}
}
},
"facets" : {
"size" : {
"terms" : {
"field" : "offers.size"
},
"facet_filter" : {
"nested" : {
"path" : "offers",
"query" : {
"match" : {
"offers.color" : "blue"
}
},
"join" : false
}
},
"nested" : "offers"
}
}
}'
The scope support for parent/child queries will be replaced by running the child query as filter in a global facet.
Search request with the current scope support:
curl -s -XPOST 'localhost:9200/products/_search' -d '{
"query" : {
"has_child" : {
"type" : "offer",
"query" : {
"match" : {
"color" : "blue"
}
},
"_scope" : "my_scope"
}
},
"facets" : {
"size" : {
"terms" : {
"field" : "size"
},
"scope" : "my_scope"
}
}
}'
The following is the functional equivalent of using the scope support with parent/child queries:
curl -s -XPOST 'localhost:9200/products/_search' -d '{
"query" : {
"has_child" : {
"type" : "offer",
"query" : {
"match" : {
"color" : "blue"
}
}
}
},
"facets" : {
"size" : {
"terms" : {
"field" : "size"
},
"global" : true,
"facet_filter" : {
"term" : {
"color" : "blue"
}
}
}
}
}'