首页 > elasticsearch排序慢的问题

elasticsearch排序慢的问题

大家有遇到过elasticsearch在查询千亿级别数据的时候,使用自带的排序方法很慢的问题问题吗?
用自带的排序:查询下来30秒,如果把排序去掉,查询200毫秒
看官方文档一直没找到解决办法,后来只能是将数据查出来之后在内存排序。


你说的是千亿级别,还是千万级别。


Enabling Doc Valuesedit

Doc values can be enabled for numeric, date, Boolean, binary, and geo-point fields, and for not_analyzed string fields. They do not currently work with analyzed string fields. Doc values are enabled per field in the field mapping, which means that you can combine in-memory fielddata with doc values:

PUT /music/_mapping/song
{
  "properties" : {
    "tag": {
      "type":       "string",
      "index" :     "not_analyzed",
      "doc_values": true
    }
  }
}

你需要优化排序的条件,es 会吧所有的数据load 到内存里去,所以,排序的如果是数字,那么缩短数字,如果是字符串,最好是不分词的字符串,你可以试试


如果是比较复杂的排序,建议使用native script的方式,性能要好些。详情见http://www.dcharm.com/?p=469


我也有排序的问题,用了function_score自定义打分,cpu扛不住

【热门文章】
【热门文章】