Xapian::TermGenerator - Parses a piece of text and generates terms.


This module takes a piece of text and parses it to produce words which are then used to generate suitable terms for indexing. The terms generated are suitable for use with Xapian::Query objects produced by the Xapian::QueryParser class.


  use Xapian;

  my $doc = new Xapian::Document();
  my $tg = new Xapian::TermGenerator();
  $tg->set_stemmer(new Xapian::Stem("english"));
  $tg->index_text("The cat sat on the mat");



TermGenerator constructor.

set_stemmer <stemmer>

Set the Xapian::Stem object to be used for generating stemmed terms.

set_stopper <stopper>

Set the Xapian::Stopper object to be used for identifying stopwords.

set_document <document>

Set the Xapian::Document object to index terms into.

get_document <document>

Get the currently set Xapian::Document object.

index_text <text> [<wdf_inc> [<prefix>]]

Indexes the text in string <text>. The optional parameter <wdf_inc> sets the wdf increment (default 1). The optional parameter <prefix> sets the term prefix to use (default is no prefix).

index_text_without_positions <text> [<wdf_inc> [<prefix>]]

Just like index_text, but no positional information is generated. This means that the database will be significantly smaller, but that phrase searching and NEAR won't be supported.

increase_termpos [<delta>]

Increase the termpos used by index_text by <delta> (default 100).

This can be used to prevent phrase searches from spanning two unconnected blocks of text (e.g. the title and body text).


Get the current term position.

set_termpos <termpos>

Set the current term position.


Return a description of this object.