Terms Lookup By Query

Add support for looking up filter terms using the results of a query.
A query or filter can be used to gather a set of results and the
specified "path" field value will be extracted from each matching
document and used as a filter term.

The query lookup is cached by default to avoid redundant lookups and
the field data cache is used during lookup and document filtering to
improve performance when the number of terms is high.
Significant performance improvement for numeric fields

Do not use BytesRef's when performing lookup on numeric fields since
the value is converted to a string and then byte copied into the
BytesRef.  We now check the field type and use the correct field data
implementation avoiding the costly string conversion.