Class | Ferret::Search::Query
In: | ext/r_search.c
Parent: | Object

## Summary

Abstract class representing a query to the index. There are a number of concrete Query implementations;

- TermQuery
- MultiTermQuery
- BooleanQuery
- PhraseQuery
- ConstantScoreQuery
- FilteredQuery
- MatchAllQuery
- RangeQuery
- WildcardQuery
- FuzzyQuery
- PrefixQuery
- Spans::SpanTermQuery
- Spans::SpanFirstQuery
- Spans::SpanOrQuery
- Spans::SpanNotQuery
- Spans::SpanNearQuery

Explore these classes for the query right for you. The queries are passed to the Searcher#search* methods.

### Query Boosts

Queries have a boost value so that you can make the results of one query more important than the results of another query when combining them in a BooleanQuery. For example, documents on Rails. To avoid getting results for train rails you might also add the tern Ruby but Rails is the more important term so you‘d give it a boost.

### Methods

== boost boost= eql? hash terms to_s

### Public Instance methods

==(p1)

call-seq;

       query.eql?(other_query) -> bool
       query == other_query -> bool

Return true if `query` equals `other_query`. Theoretically, two queries are equal if the always return the same results, no matter what the contents of the index. Practically, however, this is difficult to implement efficiently for queries like BooleanQuery since the ordering of clauses unspecified. "Ruby AND Rails" will not match "Rails AND Ruby" for example, although their result sets will be identical. Most queries should match as expected however.

query.boost

Returns the queries boost value. See the Query desription for more information on Query boosts.

query.boost = boost → boost

Set the boost for a query. See the Query desription for more information on Query boosts.

eql?(p1)

call-seq;

       query.eql?(other_query) -> bool
       query == other_query -> bool

Return true if `query` equals `other_query`. Theoretically, two queries are equal if the always return the same results, no matter what the contents of the index. Practically, however, this is difficult to implement efficiently for queries like BooleanQuery since the ordering of clauses unspecified. "Ruby AND Rails" will not match "Rails AND Ruby" for example, although their result sets will be identical. Most queries should match as expected however.

query.hash → number

Return a hash value for the query. This is used for caching query results in a hash object.

query.terms(searcher) → term_array

Returns an array of terms searched for by this query. This can be used for implementing an external query highlighter for example. You must supply a searcher so that the query can be rewritten and optimized like it would be in a real search.

query.to_s → string

Return a string representation of the query. Most of the time, passing this string through the Query parser will give you the exact Query you began with. This can be a good way to explore how the QueryParser works.

[Validate]