gpt4 book ai didi

按日期排序的 Elasticsearch 不起作用

转载 作者:行者123 更新时间:2023-11-29 02:53:09 25 4
gpt4 key购买 nike

我在 elasticsearch 上按日期排序时遇到问题。根据 elasticsearch 提供的文档 http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/_sorting.html

我用下面的代码按日期排序

{"sort":{"posted_on":{"order":"desc"}}}

下面是结果

{
"took": 3,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 305,
"max_score": null,
"hits": [
{
"_index": "ads",
"_type": "ad",
"_id": "52d6945f1d41c812bf000004",
"_score": null,
"_source": {
"category": "Cars and Bikes",
"description": "Innova 2010(V) DC",
"posted_on": "2014-09-04T18:11:57+00:00",
"slug_id": "innova-2010-v-dc",
"title": "Innova 2010(V) DC"
},
"sort": [
"57"
]
}
,
{
"_index": "ads",
"_type": "ad",
"_id": "5408accf1d41c8b8f1000001",
"_score": null,
"_source": {
"category": "",
"description": "rrrrrrrrrrfsadsadfsadfsa",
"posted_on": "2014-09-04T18:11:57+00:00",
"slug_id": "test",
"title": "test"
},
"sort": [
"57"
]
}
,
{
"_index": "ads",
"_type": "ad",
"_id": "52d6945f1d41c812bf000003",
"_score": null,
"_source": {
"category": "Cars and Bikes",
"description": "Indica DLS 2006 for immediate sale",
"posted_on": "2015-02-16T12:46:10+00:00",
"slug_id": "indica-dls",
"title": "Indica DLS"
},
"sort": [
"46"
]
}
,
{
"_index": "ads",
"_type": "ad",
"_id": "52d694981d41c812d800000a",
"_score": null,
"_source": {
"category": "Automotive",
"description": "MAHINDRA XYLO 2011 MAY Hyderabad registration for immediate sale cash party ",
"posted_on": "2015-02-16T12:46:10+00:00",
"slug_id": "mahindra-xylo-2011-may-hyderabad-registration",
"title": "MAHINDRA XYLO 2011 MAY Hyderabad registration"
},
"sort": [
"46"
]
}
,
{
"_index": "ads",
"_type": "ad",
"_id": "52d694981d41c812d8000010",
"_score": null,
"_source": {
"category": "Automotive",
"description": "SWIFT LDI 2008 Black,single owner, Hyderabad Registration, Excellent Condition",
"posted_on": "2015-02-16T12:46:10+00:00",
"slug_id": "swift-ldi-2008-black",
"title": "SWIFT LDI 2008 Black"
},
"sort": [
"46"
]
}

他们的查询有什么问题吗?谢谢,阿希什

最佳答案

只是为了回答这个问题,就像 aashish 说的那样。发生这种情况时,您可能需要查看映射字段并确保字段类型为“日期”。

您可能还想指定日期格式,如 here 中所述

关于按日期排序的 Elasticsearch 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28544428/

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