ElasticSearch Filtering aggregations from array field

前端 未结 1 545
星月不相逢
星月不相逢 2021-01-12 11:36

I am trying to do an aggregation on values in an array and also filter the buckets that are returned by a prefix. Not sure if this is possible or I am misusing the filter b

1条回答
  •  有刺的猬
    2021-01-12 12:28

    Try this, it will filter the values the buckets themselves are created for:

    {
      "size": 0,
      "aggs": {
        "colors": {
          "filter": {
            "prefix": {
              "colors": "b"
            }
          },
          "aggs": {
            "top-colors": {
              "terms": {
                "field": "colors",
                "include": {
                  "pattern": "b.*"
                }
              }
            }
          }
        }
      }
    }
    

    0 讨论(0)
提交回复
热议问题