Class: Ferret::Search::BooleanQuery
- Inherits:
-
Object
- Object
- Ferret::Search::BooleanQuery
- Defined in:
- ext/r_search.c
Overview
Summary
A BooleanQuery is used for combining many queries into one. This is best illustrated with an example.
Example
Lets say we wanted to find all documents with the term “Ruby” in the :title and the term “Ferret” in the :content field or the :title field written before January 2006. You could build the query like this.
tq1 = TermQuery.new(:title, "ruby")
tq21 = TermQuery.new(:title, "ferret")
tq22 = TermQuery.new(:content, "ferret")
bq2 = BooleanQuery.new
bq2 << tq21 << tq22
rq3 = RangeQuery.new(:written, :< => "200601")
query = BooleanQuery.new
query.add_query(tq1, :must).add_query(bq2, :must).add_query(rq3, :must)