Lucene - Term Class



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>, Accountable

Class Constructors

Following table shows the constructors for Term −

S.No. Constructors & Description
1

Term(String fld)

Constructs a Term with the given field and empty text.

2

Term(String fld, String text)

Constructs a Term with the given field and text.

3

Term(String fld, BytesRef bytes)

Constructs a Term with the given field and bytes.

4

Term(String fld, BytesRefBuilder bytesBuilder)

Constructs a Term with the given field and the bytes from a builder.

Class Methods

S.No. Method & Description
1

BytesRef bytes()

Returns the bytes of this term, these should not be modified.

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

boolean equals(Object obj)

Compares objects for equality.

4

String field()

Returns the field of this term.

5

int hashCode()

Returns the hashcode of this term.

6

long ramBytesUsed()

Return the memory usage of this object in bytes.

7

String text()

Returns the text of this term.

8

String toString()

Returns String representation.

9

static String toString(BytesRef termText)

Returns human-readable form of the term text.

Methods Inherited

This class inherits methods from the following classes −

  • java.lang.Object
lucene_searching_classes.htm
Advertisements