Lucene - TermQuery Class



TermQuery is the most commonly-used query object and is the foundation of many complex queries that Lucene can make use of.

Class Declaration

Following is the declaration for org.apache.lucene.search.TermQuery class −

public class TermQuery
   extends Query

Class Constructors

Following table shows the constructors for TermQuery −

S.No. Constructor & Description
1

TermQuery(Term t)

Constructs a query for the term t.

2

TermQuery(Term t, TermStates states)

Expert: constructs a TermQuery that will use the provided docFreq instead of looking up the docFreq against the searcher.

Class Methods

S.No. Method & Description
1

Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost)

Expert: Constructs an appropriate Weight implementation for this query.

2

boolean equals(Object other)

Returns true iff other is equal to this.

3

Term getTerm()

Returns the term of this query.

4

TermStates getTermStates()

Returns the TermStates passed to the constructor, or null if it was not passed.

5

int hashCode()

Override and implement query hash code properly in a subclass.

6

String toString(String field)

Prints a user-readable version of this query.

7

void visit(QueryVisitor visitor)

Recurse through the query tree, visiting any child queries.

Methods Inherited

This class inherits methods from the following classes −

  • org.apache.lucene.search.Query
  • java.lang.Object
lucene_searching_classes.htm
Advertisements