Is it possible to query the index for a TermEnum for all fields in the index instead of just ? Thanks, John
On Apr 9, 2007, at 10:52 AM, John Bachir wrote:> Is it possible to query the index for a TermEnum for all fields in > the index instead of just ?Err, I meant to write: "instead of just a single field"
On Apr 9, 2007, at 10:52 AM, John Bachir wrote:> Is it possible to query the index for a TermEnum for all fields in > the index instead of just a single field?Anyone have any experience with this? Judging from past discussion on this list it seems like IndexReader#terms doesn''t get used very much. John
On 4/11/07, John Bachir <john at digitalpulp.com> wrote:> > On Apr 9, 2007, at 10:52 AM, John Bachir wrote: > > > Is it possible to query the index for a TermEnum for all fields in > > the index instead of just a single field? > > Anyone have any experience with this? Judging from past discussion on > this list it seems like IndexReader#terms doesn''t get used very much.Here is an example looping over all the terms in an index; require ''rubygems'' require ''ferret'' def print_all_terms(index) index.field_infos.each do |field_info| field = field_info.name index.reader.terms(field).each {|term, freq| puts "#{field}:#{term}"} end end index = Ferret::I.new [ {:one => ''one'', :two => ''one two three''}, {:three => ''some knew terms'', :four => ''the fourth field''} ].each {|doc| index << doc} print_all_terms(index) Hope that helps. Dave -- Dave Balmain http://www.davebalmain.com/
On Apr 12, 2007, at 9:25 AM, David Balmain wrote:> def print_all_terms(index) > index.field_infos.each do |field_info| > field = field_info.name > index.reader.terms(field).each {|term, freq| puts "# > {field}:#{term}"} > end > endDavid-- thanks, this example is very helpful, but one strange problem: it seems that FieldInfo does not have a ''name'' method, and as far as I can tell there is no way to access the name of the field represented. What am I missing? Thanks, John
On Apr 13, 2007, at 11:02 AM, John Bachir wrote:> one strange problem: it seems that FieldInfo does not have a ''name'' > method, and > as far as I can tell there is no way to access the name of the field > represented. What am I missing?I just upgraded to the newest ferret, and now .name works. Thanks (again), John