jruby/docs BETA
Navigation
org.apache.lucene.search 162
C AbstractDocIdSetIterator
C AbstractKnnCollector
C AcceptDocs
C AutomatonQuery
C BlendedTermQuery
C BooleanQuery
I BoostAttribute
C BoostAttributeImpl
C BoostQuery
C BulkScorer
C ByteVectorSimilarityQuery
C CachingCollector
I CheckedIntConsumer
C CollectionTerminatedException
I Collector
I CollectorManager
C CombinedFieldQuery
C ConjunctionUtils
C ConstantScoreQuery
C ConstantScoreScorer
C ConstantScoreScorerSupplier
C ConstantScoreWeight
C ControlledRealTimeReopenThread
C DisiPriorityQueue
C DisiWrapper
C DisjunctionDISIApproximation
C DisjunctionMaxQuery
C DocAndFloatFeatureBuffer
C DocAndScoreAccBuffer
C DocIdSet
C DocIdSetBulkIterator
C DocIdSetIterator
C DocIdStream
C DocValuesRangeIterator
C DocValuesRewriteMethod
C DoubleValues
C DoubleValuesSource
C DoubleValuesSourceRescorer
C ExactPhraseMatcher
C Explanation
C FieldComparator
C FieldComparatorSource
C FieldDoc
C FieldExistsQuery
C FieldValueHitQueue
C FilterCollector
C FilterDocIdSetIterator
C FilterLeafCollector
C FilterMatchesIterator
C FilterScorable
C FilterScorer
C FilterWeight
C FilteredDocIdSetIterator
C FloatVectorSimilarityQuery
C FullPrecisionFloatVectorSimilarityValuesSource
C FuzzyQuery
C FuzzyTermsEnum
C HitQueue
C HnswQueueSaturationCollector
C ImpactsDISI
C IndexOrDocValuesQuery
C IndexSearcher
C IndexSortSortedNumericDocValuesRangeQuery
C IndriAndQuery
C IndriAndScorer
C IndriAndWeight
C IndriDisjunctionScorer
C IndriQuery
C IndriScorer
C KnnByteVectorQuery
I KnnCollector
C KnnFloatVectorQuery
C LRUQueryCache
C LateInteractionFloatValuesSource
C LateInteractionRescorer
I LeafCollector
I LeafFieldComparator
C LiveFieldValues
C LongValues
C LongValuesSource
C MatchAllDocsQuery
C MatchNoDocsQuery
I Matches
I MatchesIterator
C MatchesUtils
I MaxNonCompetitiveBoostAttribute
C MaxNonCompetitiveBoostAttributeImpl
C MaxScoreCache
C MultiCollector
C MultiCollectorManager
C MultiPhraseQuery
C MultiTermQuery
I MultiVectorSimilarity
C Multiset
C NGramPhraseQuery
C NamedMatches
C NumericDocValuesRangeQuery
C PatienceKnnVectorQuery
C PhraseMatcher
C PhraseQuery
C PhraseWeight
C PointInSetQuery
C PointRangeQuery
C PositiveScoresOnlyCollector
C PrefixQuery
E Pruning
C Query
I QueryCache
I QueryCachingPolicy
C QueryRescorer
C QueryVisitor
C ReferenceManager
I RefreshCommitSupplier
C RegexpQuery
C RescoreTopNQuery
C Rescorer
C Scorable
C ScoreCachingWrappingScorer
C ScoreDoc
E ScoreMode
C Scorer
C ScorerSupplier
C ScoringRewrite
C SearcherFactory
C SearcherLifetimeManager
C SearcherManager
C SeededKnnVectorQuery
I SegmentCacheable
C SimpleCollector
C SimpleFieldComparator
C SkipBlockRangeIterator
C SloppyPhraseMatcher
C Sort
C SortField
C SortRescorer
C SortedNumericSelector
C SortedNumericSortField
C SortedSetSelector
C SortedSetSortField
C SynonymQuery
C TaskExecutor
C TermInSetQuery
C TermQuery
C TermRangeQuery
C TermScorer
C TimeLimitingKnnCollectorManager
C TopDocs
C TopDocsCollector
C TopFieldCollector
C TopFieldCollectorManager
C TopFieldDocs
C TopKnnCollector
C TopScoreDocCollector
C TopScoreDocCollectorManager
C TopTermsRewrite
C TotalHitCountCollector
C TotalHitCountCollectorManager
C TwoPhaseIterator
C UsageTrackingQueryCachingPolicy
I VectorScorer
C Weight
C WildcardQuery
PhraseQuery — members 15+
C new(slop, field, terms)
C new(field, terms)
C new(slop, field, terms)
C new(field, terms)
M create_weight(searcher, score_mode, boost) Weight
M equals(other) boolean
M field() String
M hash_code() int
M positions() int[]
M rewrite(index_searcher) Query
M slop() int
M term_positions_cost(terms_enum) float
M terms() Term[]
M to_string(f) String
C visit(visitor)
from Query
M to_string() String

org.apache.lucene.search.PhraseQuery

class extends Query 15 members

A Query that matches documents containing a particular sequence of terms. A PhraseQuery is built by QueryParser for input like "new york".

This query may be combined with other terms or queries with a BooleanQuery.

NOTE: All terms in the phrase must match, even those at the same position. If you have terms at the same position, perhaps synonyms, you probably want MultiPhraseQuery instead which only requires one term at a position to match.
Also, Leading holes don't have any particular meaning for this query and will be ignored. For instance this query:

PhraseQuery.Builder builder = new PhraseQuery.Builder();
builder.add(new Term("body", "one"), 4);
builder.add(new Term("body", "two"), 5);
PhraseQuery pq = builder.build();
is equivalent to the below query:
PhraseQuery.Builder builder = new PhraseQuery.Builder();
builder.add(new Term("body", "one"), 0);
builder.add(new Term("body", "two"), 1);
PhraseQuery pq = builder.build();

Constructors

new

new ( int slop, String field, String[] terms )
Java: <init>(int slop, String field, String[] terms)

Create a phrase query which will match documents that contain the given list of terms at consecutive positions in field, and at a maximum edit distance of slop. For more complicated use-cases, use PhraseQuery.Builder.

new

new ( String field, String[] terms )
Java: <init>(String field, String[] terms)

Create a phrase query which will match documents that contain the given list of terms at consecutive positions in field.

new

new ( int slop, String field, BytesRef[] terms )
Java: <init>(int slop, String field, org.apache.lucene.util.BytesRef[] terms)

Create a phrase query which will match documents that contain the given list of terms at consecutive positions in field, and at a maximum edit distance of slop. For more complicated use-cases, use PhraseQuery.Builder.

new

new ( String field, BytesRef[] terms )
Java: <init>(String field, org.apache.lucene.util.BytesRef[] terms)

Create a phrase query which will match documents that contain the given list of terms at consecutive positions in field.

Class Methods

term_positions_cost

float term_positions_cost ( TermsEnum terms_enum )
Java: termPositionsCost(org.apache.lucene.index.TermsEnum termsEnum)

Returns an expected cost in simple operations of processing the occurrences of a term in a document that contains the term. This is for use by TwoPhaseIterator#matchCost implementations.

nametypedescription
terms_enumorg.apache.lucene.index.TermsEnumThe term is the term at which this TermsEnum is positioned.

Instance Methods

create_weight

Weight create_weight ( IndexSearcher searcher, ScoreMode score_mode, float boost )
Java: createWeight(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.ScoreMode scoreMode, float boost)

equals

boolean equals ( Object other )
Java: equals(Object other)

Returns true iff o is equal to this.

field

String field ( )
Java: getField() · also: get_field

Returns the field this query applies to

hash_code

int hash_code ( )
Java: hashCode()

Returns a hash code value for this object.

positions

int[] positions ( )
Java: getPositions() · also: get_positions

Returns the relative positions of terms in this phrase.

rewrite

Query rewrite ( IndexSearcher index_searcher )
Java: rewrite(org.apache.lucene.search.IndexSearcher indexSearcher)

slop

int slop ( )
Java: getSlop() · also: get_slop

Return the slop for this PhraseQuery.

The slop is an edit distance between respective positions of terms as defined in this PhraseQuery and the positions of terms in a document.

For instance, when searching for "quick fox", it is expected that the difference between the positions of fox and quick is 1. So "a quick brown fox" would be at an edit distance of 1 since the difference of the positions of fox and quick is 2. Similarly, "the fox is quick" would be at an edit distance of 3 since the difference of the positions of fox and quick is -2. The slop defines the maximum edit distance for a document to match.

More exact matches are scored higher than sloppier matches, thus search results are sorted by exactness.

terms

Term[] terms ( )
Java: getTerms() · also: get_terms

Returns the list of terms in this phrase.

to_string

String to_string ( String f )
Java: toString(String f)

Prints a user-readable version of this query.

visit

visit ( QueryVisitor visitor )
Java: visit(org.apache.lucene.search.QueryVisitor visitor)

Inherited

from Query

to_string

String to_string ( )
Java: toString()

Prints a query to a string.

this work for additional information regarding copyright ownership.