On 9/5/06, Neville Burnell <[EMAIL PROTECTED]> wrote:
> Hi Dave,
>
> I seem to be having trouble retrieving docs from the index. Am I missing
> something obvious? BTW, I am on Windows XP, Ruby 1.8.4.
>
> require 'rubygems'
> require 'ferret'
>
> p Ferret::VERSION
>
> idx = Ferret::Index::Index.new
>
> idx << {:id => 1, :name => 'Fred', :occupation => 'Toon'}
> idx << {:id => 1, :name => 'Barney', :occupation => 'Toon'}
> p idx.size
>
> doc = idx[0]
> p doc
>
> docs = []
> query = '*:fred'
> idx.search_each(query) { |doc, score| docs << idx[doc] }
> p docs.length
> p docs.first
>
> docs = []
> query = '*:toon'
> idx.search_each(query) { |doc, score| docs << idx[doc] }
> p docs.length
> p docs.first
Hi Neville,
Documents are now lazy loading so they just look like an empty hash
unless you load all the fields. So you could try this;
p docs.first.load
And you'll see all the stored fields loaded. Ofcourse, you don't need
to call the load method to access the fields. Just refrencing a field
will load it automatically.
p docs.first[:occupation]
Hope that helps,
Dave
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk