org.apache.lucene.search

Class MultiPhraseQuery

public class MultiPhraseQuery extends Query

MultiPhraseQuery is a generalized version of PhraseQuery, with an added method {@link #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 IndexReader.terms(Term), and use MultiPhraseQuery.add(Term[] terms) to add them to the query.

Version: 1.0

Author: Anders Nielsen

Method Summary
voidadd(Term term)
Add a single term at the next position in the phrase.
voidadd(Term[] terms)
Add multiple terms at the next position in the phrase.
voidadd(Term[] terms, int position)
Allows to specify the relative position of terms within the phrase.
protected WeightcreateWeight(Searcher searcher)
booleanequals(Object o)
Returns true if o is equal to this.
int[]getPositions()
Returns the relative positions of terms in this phrase.
intgetSlop()
Sets the phrase slop for this query.
inthashCode()
Returns a hash code value for this object.
Queryrewrite(IndexReader reader)
voidsetSlop(int s)
Sets the phrase slop for this query.
StringtoString(String f)
Prints a user-readable version of this query.

Method Detail

add

public void add(Term term)
Add a single term at the next position in the phrase.

See Also: add

add

public void add(Term[] terms)
Add multiple terms at the next position in the phrase. Any of the terms may match.

See Also: add

add

public void add(Term[] terms, int position)
Allows to specify the relative position of terms within the phrase.

Parameters: terms position

See Also: PhraseQuery

createWeight

protected Weight createWeight(Searcher searcher)

equals

public boolean equals(Object o)
Returns true if o is equal to this.

getPositions

public int[] getPositions()
Returns the relative positions of terms in this phrase.

getSlop

public int getSlop()
Sets the phrase slop for this query.

See Also: getSlop

hashCode

public int hashCode()
Returns a hash code value for this object.

rewrite

public Query rewrite(IndexReader reader)

setSlop

public void setSlop(int s)
Sets the phrase slop for this query.

See Also: PhraseQuery

toString

public final String toString(String f)
Prints a user-readable version of this query.
Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.