---
name: "Lucy::Index::Lexicon"
section: "3pm"
platform: "linux"
package: "liblucy-perl"
version: "0.3.3-7+b1"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/Lucy::Index::Lexicon"
---

# Lucy::Index::Lexicon(3pm)

Iterator for a field's terms.

## NAME

Lucy::Index::Lexicon - Iterator for a field's terms.

## SYNOPSIS

```
    my $lex_reader = $seg_reader->obtain('Lucy::Index::LexiconReader');
    my $lexicon = $lex_reader->lexicon( field => 'content' );
    while ( $lexicon->next ) {
       print $lexicon->get_term . "\n";
    }
```

## DESCRIPTION

A Lexicon is an iterator which provides access to all the unique terms for a given field in sorted order.

If an index consists of two documents with a 'content' field holding "three blind mice" and "three musketeers" respectively, then iterating through the 'content' field's lexicon would produce this list:

```
    blind
    mice
    musketeers
    three
```

## ABSTRACT METHODS

### seek(target)

Seek the Lexicon to the first iterator state which is greater than or equal to `"target"`.  If `"target"` is undef, reset the iterator.

### *next()*

Proceed to the next term.

Returns: true until the iterator is exhausted, then false.

### *get\_term()*

Return the current term, or undef if the iterator is not in a valid state.

### *reset()*

Reset the iterator.  *next()* must be called to proceed to the first element.

## INHERITANCE

Lucy::Index::Lexicon isa Lucy::Object::Obj.
