Class MultiPhraseQuery
MultiPhraseQuery is a generalized version of PhraseQuery, with an added
method Add(Term[]).
To use this class, to search for the phrase "Microsoft app*" first use
Add(Term) on the term "Microsoft", then find all terms that have "app" as
prefix using
MultiFields.GetFields(IndexReader).GetTerms(string)
, and use
Add(Term[])
to add them to the query.
Collection initializer note: To create and populate a
MultiPhraseQuery
in a single statement, you can use the following example as a guide:
var multiPhraseQuery = new MultiPhraseQuery() {
new Term("field", "microsoft"),
new Term("field", "office")
};
Note that as long as you specify all of the parameters, you can use either
Add(Term), Add(Term[]), or Add(Term[], int)
as the method to use to initialize. If there are multiple parameters, each parameter set
must be surrounded by curly braces.
Inheritance
MultiPhraseQuery
Assembly: Lucene.Net.dll
Syntax
public class MultiPhraseQuery : Query, IEnumerable<Term[]>, IEnumerable
Properties
Slop
Sets the phrase slop for this query.
Declaration
public virtual int Slop { get; set; }
Property Value
See Also
Methods
Add(Term)
Add a single term at the next position in the phrase.
Declaration
public virtual void Add(Term term)
Parameters
Type |
Name |
Description |
Term |
term |
|
See Also
Add(Term[])
Add multiple terms at the next position in the phrase. Any of the terms
may match.
Declaration
public virtual void Add(Term[] terms)
Parameters
Type |
Name |
Description |
Term[] |
terms |
|
See Also
Add(Term[], int)
Allows to specify the relative position of terms within the phrase.
Declaration
public virtual void Add(Term[] terms, int position)
Parameters
Type |
Name |
Description |
Term[] |
terms |
|
int |
position |
|
See Also
CreateWeight(IndexSearcher)
Expert: Constructs an appropriate Weight implementation for this query.
Only implemented by primitive queries, which re-write to themselves.
Declaration
public override Weight CreateWeight(IndexSearcher searcher)
Parameters
Returns
Overrides
Equals(object)
Returns true
if o
is equal to this.
Declaration
public override bool Equals(object o)
Parameters
Type |
Name |
Description |
object |
o |
|
Returns
Overrides
Expert: adds all terms occurring in this query to the terms set. Only
works if this query is in its rewritten (Rewrite(IndexReader)) form.
Declaration
public override void ExtractTerms(ISet<Term> terms)
Parameters
Overrides
Exceptions
GetEnumerator()
Returns an enumerator that iterates through the termArrays collection.
Declaration
public IEnumerator<Term[]> GetEnumerator()
Returns
GetHashCode()
Returns a hash code value for this object.
Declaration
public override int GetHashCode()
Returns
Overrides
GetPositions()
Returns the relative positions of terms in this phrase.
Declaration
public virtual int[] GetPositions()
Returns
GetTermArrays()
Returns a List of the terms in the multiphrase.
Do not modify the List or its contents.
Declaration
public virtual IList<Term[]> GetTermArrays()
Returns
Rewrite(IndexReader)
Declaration
public override Query Rewrite(IndexReader reader)
Parameters
Returns
Overrides
ToString(string)
Prints a user-readable version of this query.
Declaration
public override sealed string ToString(string f)
Parameters
Type |
Name |
Description |
string |
f |
|
Returns
Overrides
Implements