业务中想实现多级排序,类似最简单的多级排序:
 
问题:
1. 这种方式有什么好的优化方式
2. 除上面方法和java中使用native脚本实现多级排序还有没有其他方式实现
 
另请教一个问题:
function_score 能否实现多级排序(通过了解没有发现实现多级排序的功能,可以支持多个排序函数,但最终需要对结果做运算处理)
																				
 "sort": [
        { "date":   { "order": "desc" }},
        { "_score": { "order": "desc" }}
    ]现在业务逻辑比较复杂,使用了脚本处理多级排序,但是发现sort排序是影响查询性能的最关键因素。"sort":[
    {
      "_script" : {
        "script" : {
          "inline" : "double score = 0;return score;",
          "lang" : "painless"
        },
        "type" : "number",
        "order" : "desc"
      }
    },
    {
      "_script" : {
        "script" : {
          "inline" : "...............",
          "lang" : "painless"
        },
        "type" : "number",
        "order" : "desc"
      }
    }
]问题:
1. 这种方式有什么好的优化方式
2. 除上面方法和java中使用native脚本实现多级排序还有没有其他方式实现
另请教一个问题:
function_score 能否实现多级排序(通过了解没有发现实现多级排序的功能,可以支持多个排序函数,但最终需要对结果做运算处理)
	
1 个回复
hufuman
赞同来自: sodyu
多级的,可以在一个脚本里完成,不同级别的score差距加大
这样可以省去编译等时间,也可以减少无必要的多次计算