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.
Assembly: DistributedLucene.Net.dll
Syntax
public class MultiPhraseQuery : Query, IEnumerable<Term[]>
Properties
Name | Description |
---|---|
Slop | Sets the phrase slop for this query. |
Methods
Name | Description |
---|---|
Add(Term) | Add a single term at the next position in the phrase. |
Add(Term[]) | Add multiple terms at the next position in the phrase. Any of the terms may match. |
Add(Term[], Int32) | Allows to specify the relative position of terms within the phrase. |
CreateWeight(IndexSearcher) | |
Equals(Object) | Returns |
ExtractTerms(ISet<Term>) | Expert: adds all terms occurring in this query to the terms set. Only works if this query is in its rewritten (Rewrite(IndexReader)) form. |
GetEnumerator() | Returns an enumerator that iterates through the Lucene.Net.Search.MultiPhraseQuery.termArrays collection. |
GetHashCode() | Returns a hash code value for this object. |
GetPositions() | Returns the relative positions of terms in this phrase. |
GetTermArrays() | Returns a List of the terms in the multiphrase. Do not modify the List or its contents. |
Rewrite(IndexReader) | |
ToString(String) | Prints a user-readable version of this query. |