【问题标题】:Terms Include elastic search numeric values术语包括弹性搜索数值
【发布时间】:2015-12-29 19:10:06
【问题描述】:

我的问题是,是否有办法在 numeric field 上的 terms include 上使用 elasticsearch aggregation

我在弹性搜索中对多个字段使用通用查询,这很好,因为我的大多数字段都是string values,我可以使用include 指定唯一字段。然而,我的一个字段是 numeric value 并抛出此错误:

"cannot support regular expression style include/exclude settings as 
they can only be applied to string fields"

所以我的问题是,对于数值是否有一个相当于字符串匹配包含?我尝试使用从 9 到 9 的 range set 进行匹配,但它没有返回任何内容,不幸的是,它是由指定的范围而不是我想要的 specified field 的值键入的。任何意见将不胜感激!

谢谢!

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    您可以在array 中传递数字,例如this 以进行精确匹配

    {
      "size": 0,
      "aggs": {
        "numeric_agg": {
          "terms": {
            "field": "my_field",
            "include": [1,2,3]
          }
        }
      }
    }
    

    希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 2014-11-18
      • 1970-01-01
      • 2021-07-25
      • 2015-08-15
      • 2014-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多