Class: Ferret::Search::QueryFilter

Inherits:
Object
  • Object
show all
Defined in:
ext/r_search.c

Overview

Summary

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.

Example

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.