在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"
如果是这样,会有解决方法吗?
答案 0 :(得分: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
}
}
}
}
}
}