---
name: "Search::Xapian::TermGenerator"
section: "3pm"
platform: "linux"
package: "libsearch-xapian-perl"
version: "1.2.25.5-3+b1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Search::Xapian::TermGenerator"
---

# Search::Xapian::TermGenerator(3pm)

Parses a piece of text and generates terms.

## NAME

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

## DESCRIPTION

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 Search::Xapian::Query objects produced by the Search::Xapian::QueryParser class.

## SYNOPSIS

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

## METHODS

- new

  TermGenerator constructor.

- set\_stemmer \<stemmer\>

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

- set\_stopper \<stopper\>

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

- set\_document \<document\>

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

- get\_document \<document\>

  Get the currently set Search::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\_termpos

  Get the current term position.

- set\_termpos \<termpos\>

  Set the current term position.

- get\_description

  Return a description of this object.

## REFERENCE

```
  https://xapian.org/docs/sourcedoc/html/classXapian_1_1TermGenerator.html
```
