Anyway to figure out if a specific field has matched or not?

Greetings,

I want to query documents which have an array field of string values, and I would like to know if any of these string values have matched for the filtered documents. My use case is to know which of the returned documents (e.g. posts) are reported by the user (i.e. the array contains the user IDs of the reporters).

Kind regards

There are two "which fields matched" kinds of features: named_queries and highlighting. I'm not sure if either one fits your use case. If both fit then prefer named_queries as they are going to be lower overhead.

Thanks!

Does terms query need to be inside bool query in order to be able to use _name?