是否可以在ElasticSearch中使用字母范围使用范围聚合?

问题描述 投票:2回答:1

在ElasticSearch范围内,查询可以与文本一起使用(“ from”:“ Bread”)。

是否可以对“范围聚合”做同样的事情?

我正在尝试:

"aggs" : "slice" {
 "range" : { "ranges" : [{"from" : "Bread"}],"field" : "content.keyword"}
}

而且我得到了:

   "root_cause" : [
      {
         "type" : "number_format_exception",
         "reason" : "For input string: \"Bread\""
      }
   ],
   "reason" : "all shards failed",
   "phase" : "query",
   "caused_by" : {
      "reason" : "For input string: \"Bread\"",
      "type" : "number_format_exception",
      "caused_by" : {
         "reason" : "For input string: \"Bread\"",
         "type" : "number_format_exception"
      }
   },
   "type" : "search_phase_execution_exception"

如果是,是否有解决方法?

elasticsearch range aggregation
1个回答
0
投票

如果您要使用的是range查询,可以将其应用于terms agg:

{
  "size": 0,
  "aggs": {
    "filtered_content_terms": {
      "filter": {
        "range": {
          "content.keyword": {
            "gte": "Bread"
          }
        }
      },
      "aggs": {
        "content_terms": {
          "terms": {
            "field": "content.keyword",
            "size": 10
          }
        }
      }
    }
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.