我有如下嵌套索引结构:
{
"customersData": {
"mappings": {
"type1": {
"properties": {
"md5": {
"type": "string"
},
"uscan": {
"properties": {
"ibm": {
"properties": {
"found": {
"type": "boolean"
}
}
},
"google": {
"properties": {
"found": {
"type": "boolean"
}
}
},
"ebay": {
"properties": {
"found": {
"type": "boolean"
}
}
}
...
}
},
"plink":{"type":"string"}
}
}
}
}
}
示例数据如:uscan.ebay.found:true,uscan.ibm.found:true,uscan.google.found:false,...
每条记录可能有一百个客户,我想查询大于5的find=true(每条记录至少有5个客户find=true)。有什么想法吗?谢谢!
您可以为此使用minimum_should_match
来指定should
子句中应匹配的最小条件数。使用以下查询:
{
"query": {
"bool": {
"should": [
{
"term": {
"uscan.ibm.found": true
}
},
{
"term": {
"uscan.google.found": true
}
},
{
"term": {
"uscan.ebay.found": true
}
},
...
],
"minimum_number_should_match": 5
}
}
}