数据库中没有开始时间和结束时间字段,要求查询某一段时间内的数据,然后排序
如:index为 java-index-style-result_2019、java-index-style-result_2020
可以创建别名把 java-index-style-result_2019、java-index-style-result_2020 中的数据全部查询出来
给索引创建别名
索引名/_aliases
{"actions": [{
"add":
{"alias": "java-index-style-result",
"index": "java-index-style-result_2019"
}}]}
Java代码
排序时报错
Caused by: java.lang.IllegalArgumentException: Fielddata is disabled on text fields by default.
Set fielddata=true on [user] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory.
提示需要设置fielddata=true,默认是不开启的
POST /索引名称/type/_mapping
{
"properties": {
"字段名": {
"type": "text",
"fielddata": true
}
}
}