Is it possible to sort the results of the ES query by the value present in the named query? We have such code in Elasticsearch-dsl:
def _named_family_sample_q(family_samples_q, family_guid, quality_filters_by_family): sample_queries = [family_samples_q] quality_q = quality_filters_by_family.get(family_guid) if quality_q: sample_queries.append(quality_q) return Q('bool', must=sample_queries, _name=family_guid)
The last line is the most crucial. The query is extremely complex but ultimately we have many hits each containing a matched_query key with the family_guid named query name:
family_guids = list(raw_hit.meta.matched_queries)
We want all hits returned to be ordered by the names of the queries. If there are two names in the
matched_queries we need to get it just sorted by first and then second together.