Forum: Ferret IndexReader#terms for all fields?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D0347a9af192d23f47056bd253743dcf?d=identicon&s=25 John Bachir (Guest)
on 2007-04-09 16:56
(Received via mailing list)
Is it possible to query the index for a TermEnum for all fields in
the index instead of just ?

Thanks,
John
D0347a9af192d23f47056bd253743dcf?d=identicon&s=25 John Bachir (Guest)
on 2007-04-09 17:44
(Received via mailing list)
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"
D0347a9af192d23f47056bd253743dcf?d=identicon&s=25 John Bachir (Guest)
on 2007-04-11 00:05
(Received via mailing list)
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
B5e329ffa0cc78efbfc7ae2d084c149f?d=identicon&s=25 David Balmain (Guest)
on 2007-04-12 15:26
(Received via mailing list)
On 4/11/07, John Bachir <john@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
D0347a9af192d23f47056bd253743dcf?d=identicon&s=25 John Bachir (Guest)
on 2007-04-13 17:23
(Received via mailing list)
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
>     end

David-- 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
D0347a9af192d23f47056bd253743dcf?d=identicon&s=25 John Bachir (Guest)
on 2007-04-13 17:39
(Received via mailing list)
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
This topic is locked and can not be replied to.