Lucene - Query



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
      implements Serializable, Cloneable

Class Constructors

The following table shows a class constructor −

S.No. Constructor & Description
1

Query()

Class Methods

The following table shows the different class methods −

S.No. Method & Description
1

Object clone()

Returns a clone of this query.

2

Query combine(Query[] queries)

Expert: Called when re-writing queries under MultiSearcher.

3

Weight createWeight(Searcher searcher)

Expert: Constructs an appropriate Weight implementation for this query.

4

boolean equals(Object obj)

5

void extractTerms(Set<Term> terms)

Expert: Adds all terms occurring in this query to the terms set.

6

float getBoost()

Gets the boost for this clause.

7

Similarity getSimilarity(Searcher searcher)

Deprecated. Instead of using "runtime" subclassing/delegation, subclass the Weight instead.

8

int hashCode()

9

static Query mergeBooleanQueries(BooleanQuery... queries)

Expert: Merges the clauses of a set of BooleanQuery's into a single BooleanQuery.

10

Query rewrite(IndexReader reader)

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

11

void setBoost(float b)

Sets the boost for this query clause to b.

12

String toString()

Prints a query to a string.

13

abstract String toString(String field)

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

14

Weight weight(Searcher searcher)

Deprecated. Never ever use this method in Weight implementations. Subclasses of Query should use createWeight(org.apache.lucene.search.Searcher), instead.

Methods Inherited

This class inherits methods from the following classes −

  • java.lang.Object
lucene_searching_classes.htm
Advertisements