不为失败找理由,要为成功找方法。

long类型无法正确倒序排序

Elasticsearch | 作者 lisq123123 | 发布于2018年07月10日 | 阅读数:4061

背景:category_first,updateTime 都是long类型
category_first 有100,1001,1002等值
updateTime 只是一个精确到秒的unix时间戳

步骤:
    查询结果根据 category_first=100来搜索,根据updateTime desc倒序
问题:
    每分钟有插入新的数据,且updateTime字段是插入时间的时间戳,使用如下查询,只能查询到7.3号(只有一条)和6.28号之前的数据
{
"query": {
"bool": {
"must": [
{
"term":{
"category_first":100
}
}
]
}
},
"_source":["title","updateTime","category_first"],
"sort": {
"updateTime":"desc"
}
}

解决了,有一个脚本在删除重复数据
已邀请:

medcl - 今晚打老虎。

赞同来自:

long、float、double 都不是精确类型。

要回复问题请先登录注册