gpt4 book ai didi

elasticsearch - Elasticsearch 中的范围值搜索,不返回结果

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

我有个问题。
我试图进行大量查询,但没有一个返回任何文档。

我的数据格式如下:

{
"_index": "orders",
"_type": "order",
"_id": "AVad66hjiOD-asNwVILB",
"_score": 1,
"_source": {
"document": {
"orderID": "1337",
"sku": "awesomeSku",
"customerID": "7331",
"productID": "20490859",
"variantID": "97920239",
"createTime": "2016-07-13T13:23:19Z",
"retailPrice": "10000",
"costPrice": "10000",
"new": 123
}
}
}

我的查询:
{
"query": {
"bool": {
"filter": [
{ "range": { "new": { "gte": "20" } } }
]
}
}
}

我只是想简单地从某个地方开始,找到所有属性为“new”且值大于20的文档。
任何反馈都很棒。

编辑:

ES中的数据格式:
{
"orders": {
"mappings": {
"order": {
"properties": {
"document": {
"properties": {
"costPrice": {
"type": "string"
},
"createTime": {
"type": "string"
},
"customerID": {
"type": "string"
},
"new": {
"type": "long"
},
"orderID": {
"type": "string"
},
"productID": {
"type": "string"
},
"retailPrice": {
"type": "string"
},
"sku": {
"type": "string"
},
"variantID": {
"type": "string"
}
}
}
}
}
}
}
}

最佳答案

您需要在document.new字段上进行这样的查询,因为所有字段都嵌套在顶层document部分中:

{
"query": {
"bool": {
"filter": [
{
"range": {
"document.new": {
"gte": 20
}
}
}
]
}
}
}

关于elasticsearch - Elasticsearch 中的范围值搜索,不返回结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39020730/

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