在弹性搜索中获得分数为空

Bad*_*dri 12 elasticsearch

{"query":{"bool": {"must": {"match": {"query": ["java"] }}}}}, 
  "sort": {"_timestamp" : "desc"}}
Run Code Online (Sandbox Code Playgroud)

执行上面的查询我得到max_score_score是这样的NULL

 "max_score": null
Run Code Online (Sandbox Code Playgroud)

Alk*_*ris 19

原因是因为您使用自定义排序.由于您需要按时间戳排序,因此elasticsearch将省略评分.

有关更多信息,请访问https://www.elastic.co/guide/en/elasticsearch/guide/current/_sorting.html.

如果希望无论如何计算_score,都可以将track_scores参数设置为true.

  • 不错,将_**track_scores**_设置为*true*后,分数出来了。谢谢! (3认同)