In my case I have a list of terms displayed, from which the user can select
to be filtered on. This works very well with the terms filter, since it
have an array. Additionally, the terms filter does just fine with a single
value in the array.
The terms filter also offers much in terms of flexibility for tweaking the
execution mode and caching, which the term filter does not.
That makes me wonder about the term filter and where it should be used.
Are there any usage guidelines for one over the other? Seems that passing
an array to terms would not be a lot different over building an array of
term filters inside an or filter.
Mathias, you're correct in your observations. The only thing you might want
to be aware of is the terms filter is automatically cached, whereas an or
filter of many term filters is not automatically cached. But the results
you will get back should be the same.
Thanks Binh. Out of curiosity do you know of performance differences
between the 2 choices? it would seem that the terms filter with it's
caching may provide better performance?
On Friday, January 31, 2014 10:34:50 AM UTC-7, Binh Ly wrote:
Mathias, you're correct in your observations. The only thing you might
want to be aware of is the terms filter is automatically cached, whereas an
or filter of many term filters is not automatically cached. But the results
you will get back should be the same.
If you run the above exact query many times, the succeeding calls will be
faster since the first call will cache the result of the above filter.
The or filter is not cached by default (but you can cache it explicitly if
needed) so if you run an or filter many times, it will re-evaluate for each
succeeding call (unless you explicitly cache it).
As discussed here as well as what is stated in the documentation, the only difference is "caching".
So does this mean that if I cache the OR filter on a big list (30+) of individual term filters, it will not have any performance drawback compared to terms filter with these 30+ values?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.