gpt4 book ai didi

ruby - ElasticSearch 术语按整个字段聚合

转载 作者:数据小太阳 更新时间:2023-10-29 06:41:04 25 4
gpt4 key购买 nike

如何编写考虑整个字段值而不是单个标记的 ElasticSearch 术语聚合查询?例如,我想按城市名称聚合,但以下返回 newyorksanfrancisco 作为单独的桶,而不是纽约旧金山 作为预期的桶。

curl -XPOST "http://localhost:9200/cities/_search" -d'
{
"size": 0,
"aggs" : {
"cities" : {
"terms" : {
"field" : "city",
"min_doc_count": 10
}
}
}
}'

最佳答案

您应该在映射中修复此问题。添加一个 not_analyzed 字段。如果您还需要分析版本,您可以创建多字段。

"album": {
"city": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
}

现在在 city.raw 上创建聚合

关于ruby - ElasticSearch 术语按整个字段聚合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22798170/

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