gpt4 book ai didi

amazon-web-services - 复合字段聚合(copy_to)在Elasticsearch上不起作用

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

我在Elasticsearch(v 1.5.0)中有一个索引,该索引具有如下所示的映射:

{
"storedash": {
"mappings": {
"outofstock": {
"_ttl": {
"enabled": true,
"default": 1296000000
},
"properties": {
"CompositeSKUProductId": {
"type": "string"
},
"Hosts": {
"type": "nested",
"properties": {
"HostName": {
"type": "string"
},
"SKUs": {
"type": "nested",
"properties": {
"CompositeSKUProductId": {
"type": "string",
"index": "not_analyzed"
},
"Count": {
"type": "long"
},
"ProductId": {
"type": "string",
"index": "not_analyzed",
"copy_to": [
"CompositeSKUProductId"
]
},
"SKU": {
"type": "string",
"index": "not_analyzed",
"copy_to": [
"CompositeSKUProductId"
]
}
}
}
}
},
"Timestamp": {
"type": "date",
"format": "dateOptionalTime"
}
}
}
}
}
}

查看如何将 CompositeSKUProductId 字段创建为SKU和ProductId字段的组合。

现在,我想在该复合字段上执行聚合,但似乎不起作用;我查询的相关部分如下所示:
        "aggs": {
"hostEspecifico": {
"filter": {
"term": { "Hosts.HostName": "www.example.com"}
},
"aggs": {
"skus": {
"nested": {
"path": "Hosts.SKUs"
},
"aggs": {
"valores": {
"terms": {
"field": "Hosts.SKUs.CompositeSKUProductId", "order": { "media": "desc" }, "size": 100 },
"aggs": {
"media": {
"avg": {
"field": "Hosts.SKUs.Count"
}
}

}
}
}
}
}
}
}

这是,此聚合返回了零个存储桶,就好像它不在那里。

我检查了是否只有将 CompositeSKUProductId 更改为另一个字段,例如 ProductId ,相同的查询才有效。

关于如何解决问题有什么想法?

N.B .: 我正在使用AWS Elasticsearch Service,该服务不允许编写脚本。

最佳答案

这里的问题是您误解了copy_to功能的概念。它只是复制各个字段的字段值,而并没有按照您期望的方式组合

如果SKU为123并且产品ID为456,则复合字段会将其作为单独值而不是123456。您可以通过查询字段来验证这一点。

您可能必须在服务器端执行此操作,理想情况下是使用脚本,但不允许这样做。就个人而言,我们使用了AWS ES服务,但遇到了多个问题,主要是无法更改elasticsearch.yml文件并且无法使用脚本。您可能需要查看Found。

希望这可以帮助!

关于amazon-web-services - 复合字段聚合(copy_to)在Elasticsearch上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35074412/

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