弹跳搜索聚合以。开头

时间:2017-08-07 15:16:22

标签: elasticsearch filter aggregation

有没有办法为terms聚合添加过滤器,所以我只得到以某些字符串开头的过滤器?

我从这里开始:

{
  "query": {
    "match_all": {}
  },
  "aggs": {
    "address": {
      "terms": {
        "field": "address"
      }
    }
  }
}

1 个答案:

答案 0 :(得分:1)

使用include or exclude parameters

{
  "query": {
    "match_all": {}
  },
  "aggs": {
    "address": {
      "terms": {
        "field": "address",
        "include": "Main.*"     <-- add this
      }
    }
  }
}