Class | Ferret::Index::TermEnum
In: | ext/r_index.c
Parent: | Object

## Summary

The TermEnum object is used to iterate through the terms in a field. To get a TermEnum you need to use the IndexReader#terms(field) method.

## Example

      te = index_reader.terms(:content)

      te.each {|term, doc_freq| puts "#{term} occured #{doc_freq} times" }

      # or you could do it like this;
      te = index_reader.terms(:content)

      while te.next?
        puts "#{te.term} occured in #{te.doc_freq} documents in the index"
      end

### Methods

doc_freq each field= next? set_field skip_to term

### Public Instance methods

term_enum.doc_freq → integer

Returns the document frequency of the current term pointed to by the enum. That is the number of documents that this term appears in. The method should only be called after a successful call to TermEnum#next.

term_enum.each {|term, doc_freq| do_something() } → term_count

Iterates through all the terms in the field, yielding the term and the document frequency.

term_enum.set_field(field) → self

Set the field for the term_enum. The field value should be a symbol as usual. For example, to scan all title terms you‘d do this;

      term_enum.set_field(:title).each do |term, doc_freq|
        do_something()
      end

term_enum.next → term_string

Returns the next term in the enumeration or nil otherwise.

term_enum.set_field(field) → self

Set the field for the term_enum. The field value should be a symbol as usual. For example, to scan all title terms you‘d do this;

      term_enum.set_field(:title).each do |term, doc_freq|
        do_something()
      end

term_enum.skip_to(target) → term

Skip to term `target`. This method can skip forwards or backwards. If you want to skip back to the start, pass the empty string "". That is;

      term_enum.skip_to("")

Returns the first term greater than or equal to `target`

term_enum.term → term_string

Returns the current term pointed to by the enum. This method should only be called after a successful call to TermEnum#next.

[Validate]