Class | Ferret::Index::TermEnum |
In: |
ext/r_index.c
|
Parent: | Object |
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.
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
Iterates through all the terms in the field, yielding the term and the document frequency.
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
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
Returns the current term pointed to by the enum. This method should only be called after a successful call to TermEnum#next.