Class: Ferret::Index::TermDocEnum
- Inherits:
-
Object
- Object
- Ferret::Index::TermDocEnum
- Defined in:
- ext/r_index.c
Overview
Summary
Use a TermDocEnum to iterate through the documents that contain a particular term. You can also iterate through the positions which the term occurs in a document.
Example
tde = index_reader.term_docs_for(:content, "fox")
tde.each do |doc_id, freq|
puts "fox appeared #{freq} times in document #{doc_id}:"
positions = []
tde.each_position {|pos| positions << pos}
puts " #{positions.join(', ')}"
end
# or you can do it like this;
tde.seek(:title, "red")
while tde.next?
puts "red appeared #{tde.freq} times in document #{tde.doc}:"
positions = []
while pos = tde.next_position
positions << pos
end
puts " #{positions.join(', ')}"
end