Lucene - Term


Advertisements


This class is the lowest unit of searching. It is similar to Field in indexing process.

Class Declaration

Following is the declaration for org.apache.lucene.index.Term class −

public final class Term
   extends Object
      implements Comparable<Term>, Serializable

Class Constructors

The following table shows a list of class constructors −

S.No. Constructor & Description
1

Term(String fld)

Constructs a Term with the given field and empty text.

2

Term(String fld, String txt)

Constructs a Term with the given field and text.

Class Methods

The following table shows the different class methods −

S.No. Method & Description
1

void addDocument(Document doc)

Adds a document to this index.

2

int compareTo(Term other)

Compares two terms, returning a negative integer if this term belongs before the argument, zero if this term is equal to the argument, and a positive integer if this term belongs after the argument.

3

Term createTerm(String text)

Optimized construction of new Terms by reusing same field as this Term - avoids field.intern() overhead.

4

boolean equals(Object obj)

5

String field()

Returns the field of this term, an interned string.

6

int hashCode()

7

String text()

Returns the text of this term.

8

String toString()

Methods Inherited

This class inherits methods from the following classes −

  • java.lang.Object

lucene_searching_classes.htm

Advertisements