On 3/2/07, Caleb Clausen <[EMAIL PROTECTED]> wrote:
> Dave, thank you so much for the 0.11 release(s). You have solved many
> problems for me. As part of my appreciation for your good works, I am
> offering up for public consideration a silly little class that I wrote.
> (Code is below.) This class offers a simplified Hash-like interface to
> (a very restricted subset of) Ferret. Hence I call it FerretHash.
>
> FerretHash comes with its very own pet Ferret bug. Run the crude unit
> test to see the problem. (Long story short, it looks like term
> frequency, as reported by IndexReader#terms, does not take deletions
> into account.)
Hey Caleb,
Unfortunately it would be too inefficient to change all of the term
counts when you delete a document. What you can do is optimize the
index before you iterate over the terms. For example;
def keys
@writer.optimize
reader=Ferret::Index::IndexReader.new(@name)
result=reader.terms(:key).extend(Enumerable).map{|term,freq|
freq==1 or fail
term
}
reader.close
return result
end
Hope that makes sense.
--
Dave Balmain
http://www.davebalmain.com/
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk