gpt4 book ai didi

elasticsearch - 术语包括 Elasticsearch 数值

转载 作者:行者123 更新时间:2023-12-03 01:03:10 28 4
gpt4 key购买 nike

我的问题是是否有办法使用 terms includenumeric fieldelasticsearch aggregation .

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

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

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

谢谢!

最佳答案

您可以在 array 中传递数字喜欢 this精确匹配

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

希望这可以帮助!

关于elasticsearch - 术语包括 Elasticsearch 数值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34517464/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com