Philippe April
2007-May-30 17:40 UTC
[Ferret-talk] A way to get all the words from an index?
Hi, I am just wondering if there''s a way to get all the words from an index. Basically, all the words that have been indexed (excluding the stopwords if I''m using the stopwords analyzer, etc.) The fields I''m putting in are not :stored in the index. The idea is to implement a "did you mean?" mecanism, which is based on the content of the index, not on a dictionary... Possible? Thank you! Philippe April
On May 30, 2007, at 1:40 PM, Philippe April wrote:> I am just wondering if there''s a way to get all the words from an > index. Basically, all the words that have been indexed (excluding the > stopwords if I''m using the stopwords analyzer, etc.)perhaps something like this: th_hash = {} Resource.aaf_index.ferret_index.reader.terms(:body).each {|t, f| term_hash[t] = f } th_sorted = term_hash.sort {|a,b| a[1]<=>b[1]}.reverse Cheers, John -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ferret-talk/attachments/20070530/87e0ca45/attachment.html
On May 30, 2007, at 3:49 PM, John Bachir wrote:> Resource.aaf_index.ferret_index.reader.terms(:body).each {|t, f| > term_hash[t] = f }(Resource is the model being indexed) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ferret-talk/attachments/20070530/e07d64f5/attachment.html
Philippe April
2007-May-30 22:26 UTC
[Ferret-talk] A way to get all the words from an index?
John, This is exactly what I''ve been looking for... I guess I didn''t know about the reader! Thank you, Philippe On 30-May-07, at 3:49 PM, John Bachir wrote:> On May 30, 2007, at 1:40 PM, Philippe April wrote: >> I am just wondering if there''s a way to get all the words from an >> index. Basically, all the words that have been indexed (excluding the >> stopwords if I''m using the stopwords analyzer, etc.) > > > perhaps something like this: > > th_hash = {} > Resource.aaf_index.ferret_index.reader.terms(:body).each {|t, f| > term_hash[t] = f } > th_sorted = term_hash.sort {|a,b| a[1]<=>b[1]}.reverse > > Cheers, > John > > _______________________________________________ > Ferret-talk mailing list > Ferret-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/ferret-talk-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ferret-talk/attachments/20070530/627a7771/attachment-0001.html