Skip to main content
 首页 » 编程设计

python之如何在 elasticsearch-dsl python 中启用 track_scores

2025年05月04日32sharpest

我正在使用 elasticsearch dsl 在 elasticsearch 上进行搜索:https://elasticsearch-dsl.readthedocs.org/en/latest/

如何为查询启用 track_scores?

我知道 elasticsearch 支持它:https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-sort.html#_track_scores

只是不知道如何在 Elasticsearch-dsl 中做同样的事情

请您参考如下方法:

我发现文档中提到了这一点:

http://elasticsearch-dsl.readthedocs.org/en/latest/search_dsl.html#extra-properties-and-parameters

s = s.extra(track_scores=True) 

这有效。