繁体   English   中英

Elasticsearch嵌套查询以获取阈值

[英]Elasticsearch nested query for getting threshold hit

我有嵌套的索引结构,如下所示:

{
   "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,...

每个记录可能有一百个客户,我想查询found = true大于5(每个记录至少有5个客户found = 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
    }
  }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM