2015-07-10 70 views
1

我想做一个现场崩溃排名靠前的聚集,正是因为这里记载:弹性搜索top_hits使用Lucene表达聚集

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-top-hits-aggregation.html#_field_collapse_example

特别是,这部分是一个问题:

"top_hit": { 
    "max": { 
     "script": "_score" 
    } 
} 

由于生产环境配置为:

script.disable_dynamic: sandbox 

这意味着我不能使用Groovy脚本,没有沿着这些路线得到一个错误:如果我更改查询,像这样

nested: ScriptException[dynamic scripting for [groovy] disabled]; 

"top_hit": { 
    "max": { 
     "lang": "expression", 
     "script": "_score" 
    } 
} 

我得到一个不同类型的错误:

nested: IllegalStateException[Expressions referencing the score can only be used for sorting]; 

弹性搜索版本是1.5.2。有没有办法做到我想要的(使用lucene表达式)?

回答