It it possible to use the Explain API (https://www.elastic.co/guide/en/elasticsearch/reference/current/search-explain.html) and if not what would be the best way to use an existing query defined with this library for an explain call?
Any pointers in the right direction, would be greatly appreciated!
I use .explain() provided by the lower level elasticsearch-py library, which this higher level elasticsearch-dsl-py builds upon.
Assuming that you have an elasticsearch-py client called es and an elasticseach-dsl-py query called s, you can get the query explanation like so:
explanation = es.explain(my_index_name, some_doc_id, body=s.to_dict())
This explanation tells you why your document ID some_doc_id matches (or doesn't match) your query s.
Hope that helps! 馃槃
Thanks for answering the question @brainix. My only recommendation to add to your answer is to use keyword arguments within es.explain():
explanation = es.explain(index=my_index_name, id=some_doc_id, body=s.to_dict())
Most helpful comment
Thanks for answering the question @brainix. My only recommendation to add to your answer is to use keyword arguments within
es.explain():