其他分享
首页 > 其他分享> > 【ElasticSearch】排序报错

【ElasticSearch】排序报错

作者:互联网

数据库中没有开始时间和结束时间字段,要求查询某一段时间内的数据,然后排序

如: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
    }
  }
}

标签:index,style,java,fielddata,2019,ElasticSearch,result,报错,排序
来源: https://www.cnblogs.com/yan-sh/p/13746067.html