Class | Ferret::Search::QueryFilter |
In: |
ext/r_search.c
|
Parent: | cFilter |
QueryFilter can be used to restrict one queries results by another queries results, basically "and"ing them together. Of course you could easily use a BooleanQuery to do this. The reason you may choose to use a QueryFilter is that Filter results are cached so if you have one query that is often added to other queries you may want to use a QueryFilter for performance reasons.
Let‘s say you have a field +:approved+ which you set to yes when a document is approved for display. You‘ll probably want to add a Filter which filters approved documents to display to your users. This is the perfect use case for a QueryFilter.
filter = QueryFilter.new(TermQuery.new(:approved, "yes"))
Just remember to use the same QueryFilter each time to take advantage of caching. Don‘t create a new one for each request. Of course, this won‘t work in a CGI application.