Hmm, could you clarify what do you want to do more or show some simple example?
There is a python client of Elasticsearch, but it only works according to its API. I didn't understand what is your trouble.
As it can be said at the moment, why the "part of the _source" is not indexed as fields in the Elasticsearch index (if then, you can sort the "hits" by the field)?
I suppose you queried terms query to query those documents whose "document_id" field is in the list of terms.
Terms query only filter documents which match the condition. The documents are of course not aligned as the same position as the terms list and they are sorted by _score as default.
Sorting search results mainly spports descending or ascending of some fields and not supports sorting according to some list.
If you want to align the sort result, you have to use
If you are using python client and the result size is small, I recommend to sort by client side. If the result size is big, consider querying multiple times for each single term query.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.