On 4/11/07, John Bachir <[EMAIL PROTECTED]> 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/
_______________________________________________
Ferret-talk mailing list
[EMAIL PROTECTED]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to