【问题标题】:Elastic Search Terms aggregation is not working properly based on terms filter list基于术语过滤器列表的弹性搜索术语聚合无法正常工作
【发布时间】:2018-01-25 13:25:31
【问题描述】:

以下是我的查询:

{
  "size" : 0,
  "query" : {
    "bool" : {
      "must" : {
        "match_all" : { }
      },
      "filter" : {
        "bool" : {
          "must" : [ {
            "terms" : {
              "unblindMemberId" : [ "first", "erw", "810182628017", "ewrew", "swer", "rew", "wer", "ewr", "ewr", "r", "r", "dsf", "810218592401", "sd", "s", "last" ]
            }
          }, {
            "bool" : {
              "must" : {
                "exists" : {
                  "field" : "udf7_lab"
                }
              }
            }
          } ]
        }
      }
    }
  },
  "aggregations" : {
    "members" : {
      "terms" : {
        "field" : "unblindMemberId"
      },
      "aggregations" : {
        "top_risk" : {
          "top_hits" : {
            "size" : 1,
            "_source" : {
              "includes" : [ "udf7_lab" ],
              "excludes" : [ "" ]
            },
            "sort" : [ {
              "svc_service_date" : {
                "order" : "desc"
              }
            } ]
          }
        }
      }
    }
  }
}

在上述查询术语中,聚合没有按预期工作。 第一个元素的数据,即第一个元素没有被拉取。但是,当 unblindMemberId 的最后一个元素被删除时,即。最后的。正在拉取 first 的数据。 此外,当仅添加第一个和最后一个元素时 IE。 unblindMemberId:["first","last"] 正在为这两个 id 提取记录。

当查询在没有聚合的情况下执行时,条款过滤器工作正常,因为所有的 unblindMemberIds 都被拉出,包括第一个和最后一个 id。

列表中除 first 和 last 之外的其他几条记录也没有被拉取。

在我看来,

"aggregations" : {
    "members" : {
      "terms" : {
        "field" : "unblindMemberId"
      }
}

此特定聚合无法提取所需的记录。我无法确定原因,因为术语聚合的基本功能不起作用。非常感谢任何帮助。

【问题讨论】:

    标签: json elasticsearch


    【解决方案1】:

    问题在于术语聚合。我没有设置 size=0 因为在未设置 size 时默认只提取 10 个数据。因此我通过添加大小来解决:

    "terms": {
            "field": "unblindMemberId",
            "size":0
          }
    

    【讨论】:

      猜你喜欢
      • 2019-09-10
      • 1970-01-01
      • 1970-01-01
      • 2021-07-03
      • 2015-08-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-18
      相关资源
      最近更新 更多