Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > ruby ferret question -> how to get list of values for a given term ?

Reply
Thread Tools

ruby ferret question -> how to get list of values for a given term ?

 
 
didier.prophete@gmail.com
Guest
Posts: n/a
 
      12-05-2005
hi all,

So I have a ferret question. Suppose I have a bunch of documents I
indexed using ferret. For the sake of simplicity, all my documents have
basically 1 relevant field: "city", which I set up during indexing.

So my question is: how do I get all the different values for 'city' ?
(without having to go through every single document).

There's got to be something that can tell me all the different cities
used in all my document, like ['NY', 'SF', 'LA'] (assuming all my
documents are either in LA, SF or NY)

Thanks for your help

-Didier

ps: I know that I can already get the list of 'field names' using:
reader = Index::IndexReader.open(<index dir>)
p reader.get_field_names
but I can't seem to find the missing link to get to the list of values
for a given term...

 
Reply With Quote
 
 
 
 
David Balmain
Guest
Posts: n/a
 
      12-05-2005
On 12/5/05, <> wrote:
> hi all,
>
> So I have a ferret question. Suppose I have a bunch of documents I
> indexed using ferret. For the sake of simplicity, all my documents have
> basically 1 relevant field: "city", which I set up during indexing.
>
> So my question is: how do I get all the different values for 'city' ?
> (without having to go through every single document).
>
> There's got to be something that can tell me all the different cities
> used in all my document, like ['NY', 'SF', 'LA'] (assuming all my
> documents are either in LA, SF or NY)


Hi Didier,

Something like this. I don't have time to test it but it should be pretty c=
lose.

reader =3D Index::IndexReader.open(<index dir>)
term_enum =3D reader.terms_from(Term.new("city", ""));
cities =3D []
while (term_enum.term.field =3D=3D "city")
cities << term_enum.term.text
break if not term_enum.next?
end

Cheers,
Dave

> Thanks for your help
>
> -Didier
>
> ps: I know that I can already get the list of 'field names' using:
> reader =3D Index::IndexReader.open(<index dir>)
> p reader.get_field_names
> but I can't seem to find the missing link to get to the list of values
> for a given term...
>
>
>



 
Reply With Quote
 
 
 
 
didier.prophete@gmail.com
Guest
Posts: n/a
 
      12-05-2005
Exactly what I needed.
thanks a bunch dave,

-Didier

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Many ferret owners do not know how to properly care for and maintain a ferret qlnjhcxmajpd@yahoo.com Ruby 0 05-22-2006 05:04 PM
Days in a given date range for a given month......... Lord0 Java 1 04-19-2006 04:54 PM
[ANN] Ferret 0.3.0 (port of Apache Lucene to pure ruby) David Balmain Ruby 2 12-03-2005 12:36 AM
[ANN] Ferret 0.2.1 (port of Apache Lucene to pure ruby) David Balmain Ruby 5 11-15-2005 05:23 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57