我希望能够选择没有任何符合特定条件的 child 的 parent 。我以为如果这样做:
{
"has_child": {
"max_children": 0,
"type": "event",
"filter": {
"bool": {
"must": [
{
"bool": {
"must": [
{
"term": {
"cs_e": "eventF"
}
}
],
"should": [],
"mustNot": []
}
}
],
"should": [],
"mustNot": []
}
}
}
}
那么这将使我返回最多有0个 child 的 parent -即不匹配的 parent 。但是,奇怪的是,我确实从查询中返回了一个父级,并且那个父级有一个匹配的子级。
这是预期的吗? (可能是我在某个地方搞砸了或被误解了)?
非常感谢!
最佳答案
在“ES 5.0的重大变化”中找到了以下引用:
https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking_50_search_changes.html
When the max_children parameter was set to 0 on the has_child query then there was no upper limit on how many child documents were allowed to match. Now, 0 really means that zero child documents are allowed. If no upper limit is needed then the max_children parameter shouldn’t be specified at all.
因此在ES> 5.0中应该可以使用,但是由于某些原因,max_children = 0在5.3.0中实际上不起作用
关于elasticsearch - 可以在elasticsearch has_child查询中使用max_children为0吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34497722/