How to enable track_scores in elasticsearch-dsl py

2019-06-13 07:57发布

问题:

I am using elasticsearch dsl to search on elasticsearch : https://elasticsearch-dsl.readthedocs.org/en/latest/

How can i enable track_scores for the query ?

I know its supported in elasticsearch: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-sort.html#_track_scores

Just dont know how to do the same in Elasticsearch-dsl

回答1:

I found this mentioned in the documentation:

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

s = s.extra(track_scores=True)

This worked.