The MatchingFields field expression will return all fields from the search query that contributed to a match for the returned document. This is useful when the query is a large OR query across multiple fields and it is desired to know which fields from the query resulted in the match. NOTE: this is an expensive field expression to compute. It should not be applied unless the result will actually be used.
- PARAMETERS - comma separated list of parameters to apply to matching fields function
- minimumboost - minimum boost required for a query term to be included in matching fields computation.
MATCHINGFIELDS() AS matching.fields
QueryRequest request = new QueryRequest("OR(title:a, content:b, author:c)"); request.addField( new MatchingFields("MatchingFields") ); // ... (Perform Search) // Returned documents will have a "MatchingFields" field that will contain one or more values. // each value will be the name of a field that matched ("title", "content", or "author" in this case)