Search code examples
pythonelasticsearchelasticsearch-dsl

How to enable track_scores in elasticsearch-dsl python


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


Solution

  • 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.