gpt4 book ai didi

elasticsearch - 如何使Elasticsearch date_histogram facet在嵌套项目上工作

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

我正在使用Kibana 3查询我的Elasticsearch服务器。 Kibana提供了一个date_histogram可视化面板来显示我为产品收集的价格。每个产品可以包含任意数量的价格以及相应的日期。价格被实现为每个文档中的嵌套字段。

Kibana创建以下查询,将其应用于所有文档时,该查询可以正常工作。

curl -XGET 'http://localhost.com:9200/vendor2/_search?pretty' -d '{
"facets": {
"1": {
"date_histogram": {
"key_field": "Prices.Fetched",
"value_field": "Prices.Price",
"interval": "1m"
},
"nested": "Prices",
"facet_filter": {
"fquery": {
"query": {
"filtered": {
"query": {
"query_string": {
"query": "*"
}
},
"filter": {
"bool": {
"must": [
{
"match_all": {}
},
{
"bool": {
"must": [
{
"match_all": {}
}
]
}
}
]
}
}
}
}
}
}
}
},
"size": 0
}'

当我尝试使用date_histogram可视化 单个产品的价格随时间变化时,就会出现问题。 Kibana提供了过滤到特定文档的功能。例如,基于其ID / SKU。

但是,date_histogram构面保持为空。

这是一个示例...任何人都可以告知该查询有什么问题吗?
curl -XGET 'http://localhost.com:9200/vendor2/_search?pretty' -d '{   "facets": {
"1": {
"date_histogram": {
"key_field": "Prices.Fetched",
"value_field": "Prices.Price",
"interval": "1m"
},
"nested": "Prices",
"facet_filter": {
"fquery": {
"query": {
"filtered": {
"query": {
"query_string": {
"query": "*"
}
},
"filter": {
"bool": {
"must": [
{
"match_all": {}
},
{
"fquery": {
"query": {
"field": {
"sku": {
"query": "\"AZF78FH77\""
}
}
},
"_cache": true
}
},
{
"bool": {
"must": [
{
"match_all": {}
}
]
}
}
]
}
}
}
}
}
}
} }, "size": 0 }'

最佳答案

问题是查询中已包含双引号(请注意查询中的转义引号)。这将导致ElasticSearch寻找'“AZF78FH77”'的SKU,而不是'AZF78FH77'

尝试在Kibana中查询,但查询框中没有引号。

关于elasticsearch - 如何使Elasticsearch date_histogram facet在嵌套项目上工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19777285/

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