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[], Int32)
as the method to use to initialize. If there are multiple parameters, each parameter set
must be surrounded by curly braces.
Inheritance
System.Object
MultiPhraseQuery
Assembly: Lucene.Net.dll
Syntax
public class MultiPhraseQuery : Query, IEnumerable<Term[]>
Properties
|
Improve this Doc
View Source
Slop
Sets the phrase slop for this query.
Declaration
public virtual int Slop { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
See Also
Methods
|
Improve this Doc
View Source
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
|
Improve this Doc
View Source
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
|
Improve this Doc
View Source
Add(Term[], Int32)
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 |
|
System.Int32 |
position |
|
See Also
|
Improve this Doc
View Source
CreateWeight(IndexSearcher)
Declaration
public override Weight CreateWeight(IndexSearcher searcher)
Parameters
Returns
Overrides
|
Improve this Doc
View Source
Equals(Object)
Returns true
if o
is equal to this.
Declaration
public override bool Equals(object o)
Parameters
Type |
Name |
Description |
System.Object |
o |
|
Returns
Type |
Description |
System.Boolean |
|
Overrides
|
Improve this Doc
View Source
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
Type |
Name |
Description |
ISet<Term> |
terms |
|
Overrides
|
Improve this Doc
View Source
GetEnumerator()
Returns an enumerator that iterates through the Lucene.Net.Search.MultiPhraseQuery.termArrays collection.
Declaration
public IEnumerator<Term[]> GetEnumerator()
Returns
Type |
Description |
IEnumerator<Term[]> |
An enumerator that can be used to iterate through the Lucene.Net.Search.MultiPhraseQuery.termArrays collection.
|
|
Improve this Doc
View Source
GetHashCode()
Returns a hash code value for this object.
Declaration
public override int GetHashCode()
Returns
Type |
Description |
System.Int32 |
|
Overrides
|
Improve this Doc
View Source
GetPositions()
Returns the relative positions of terms in this phrase.
Declaration
public virtual int[] GetPositions()
Returns
Type |
Description |
System.Int32[] |
|
|
Improve this Doc
View Source
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
Type |
Description |
IList<Term[]> |
|
|
Improve this Doc
View Source
Rewrite(IndexReader)
Declaration
public override Query Rewrite(IndexReader reader)
Parameters
Returns
Overrides
|
Improve this Doc
View Source
ToString(String)
Prints a user-readable version of this query.
Declaration
public override sealed string ToString(string f)
Parameters
Type |
Name |
Description |
System.String |
f |
|
Returns
Type |
Description |
System.String |
|
Overrides
Implements
IEnumerable<>