Possible to sort and filter on length(matched_queries)?

Hello. I'm using named queries which generates a "field" on returned documents called matched_queries which is an array of the names of the queries that matched.

Is it possible to sort and filter on the cardinality of matched_queries?

Or perhaps use scripting to make a field match_queries_length that can then be sorted / filtered on?

Thanks for the help.

Figured it out.

If I construct my query such that nothing contributes to scoring except the named queries, then I can simply sort by document score and it will have the desired effect. :slight_smile:

Hey! Great! Any day you can maneuver your problem into "sort by score" is a good day.