org.apache.lucene.search

Class MultiPhraseQuery

Implemented Interfaces:
Cloneable, Serializable

public class MultiPhraseQuery
extends Query

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 IndexReader.terms(Term), and use MultiPhraseQuery.add(Term[] terms) to add them to the query.
Version:
1.0
Author:
Anders Nielsen
See Also:
Serialized Form

Method Summary

void
add(Term term)
Add a single term at the next position in the phrase.
void
add(Term[] terms)
Add multiple terms at the next position in the phrase.
void
add(Term[] terms, int position)
Allows to specify the relative position of terms within the phrase.
protected Weight
createWeight(Searcher searcher)
boolean
equals(Object o)
Returns true if o is equal to this.
void
extractTerms(Set terms)
int[]
getPositions()
Returns the relative positions of terms in this phrase.
int
getSlop()
Sets the phrase slop for this query.
List
getTermArrays()
Returns a List of the terms in the multiphrase.
int
hashCode()
Returns a hash code value for this object.
Query
rewrite(IndexReader reader)
void
setSlop(int s)
Sets the phrase slop for this query.
String
toString(String f)
Prints a user-readable version of this query.

Methods inherited from class org.apache.lucene.search.Query

clone, combine, createWeight, extractTerms, getBoost, getSimilarity, mergeBooleanQueries, rewrite, setBoost, toString, toString, weight

Method Details

add

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

add

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

add

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

createWeight

protected Weight createWeight(Searcher searcher)
            throws IOException
Overrides:
createWeight in interface Query

equals

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

extractTerms

public void extractTerms(Set terms)
Overrides:
extractTerms in interface Query

getPositions

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

getSlop

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

getTermArrays

public List getTermArrays()
Returns a List of the terms in the multiphrase. Do not modify the List or its contents.

hashCode

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

rewrite

public Query rewrite(IndexReader reader)
Overrides:
rewrite in interface Query

setSlop

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

toString

public final String toString(String f)
Prints a user-readable version of this query.
Overrides:
toString in interface Query

Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.