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

## Summary

MultiTermQuery matches documents that contain one of a list of terms in a specific field. This is the basic building block for queries such as;

- PrefixQuery
- WildcardQuery
- FuzzyQuery

MultiTermQuery is very similar to a boolean "Or" query. It is highly optimized though as it focuses on a single field.

## Example

      multi_term_query = MultiTermQuery.new(:content, :max_term => 10)

      multi_term_query << "Ruby" << "Ferret" << "Rails" << "Search"

### Methods

<< add_term default_max_terms default_max_terms= new

### Public Class methods

MultiTermQuery.default_max_terms → number

Get the default value for +:max_terms+ in a MultiTermQuery. This value is also used by PrefixQuery, FuzzyQuery and WildcardQuery.

MultiTermQuery.default_max_terms = max_terms → max_terms

Set the default value for +:max_terms+ in a MultiTermQuery. This value is also used by PrefixQuery, FuzzyQuery and WildcardQuery.

MultiTermQuery.new(field, options = {}) → multi_term_query

Create a new MultiTermQuery on field `field`. You will also need to add terms to the query using the MultiTermQuery#add_term method.

There are several options available to you when creating a MultiTermQueries;

### Options

:max_terms: | You can specify the maximum number of terms that can be added to the query. This is to prevent memory usage overflow, particularly when don‘t directly control the addition of terms to the Query object like when you create Wildcard queries. For example, searching for "content:*" would cause problems without this limit.
:min_score: | The minimum score a term must have to be added to the query. For example you could implement your own wild-card queries that gives matches a score. To limit the number of terms added to the query you could set a lower limit to this score. FuzzyQuery in particular makes use of this parameter.

### Public Instance methods

multi_term_query.add_term(term, score = 1.0) → self
multi_term_query << term1 << term2 << term3 → self

Add a term to the MultiTermQuery with the score 1.0 unless specified otherwise.

multi_term_query.add_term(term, score = 1.0) → self
multi_term_query << term1 << term2 << term3 → self

Add a term to the MultiTermQuery with the score 1.0 unless specified otherwise.

[Validate]