Lucene - Query Class



Query is an abstract class and contains various utility methods and is the parent of all types of queries that Lucene uses during search process.

Class Declaration

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

public abstract class Query
   extends Object

Class Constructors

Following table shows the constructors for Query −

S.No. Constructor & Description
1

Query()

Constructs a Query object.

Class Methods

S.No. Method & Description
1

protected final int classHash()

Provides a constant integer for a given class, derived from the name of the class.

2

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

Expert: Constructs an appropriate Weight implementation for this query.

3

abstract boolean equals(Object obj)

Override and implement query instance equivalence properly in a subclass.

4

abstract int hashCode()

Override and implement query hash code properly in a subclass.

5

Query rewrite(IndexSearcher indexSearcher)

Expert: called to re-write queries into primitive queries.

6

protected final boolean sameClassAs(Object other)

Utility method to check whether other is not null and is exactly of the same class as this object's class.

7

final String toString()

Prints a query to a string.

8

abstract String toString(String field)

Prints a query to a string, with field assumed to be the default field and omitted.

9

abstract void visit(QueryVisitor visitor)

Recurse through the query tree, visiting any child queries.

Methods Inherited

This class inherits methods from the following classes −

  • java.lang.Object
lucene_searching_classes.htm
Advertisements