On 3/14/07, Xavier Belanche <[EMAIL PROTECTED]> wrote:
> <snip/>
>
> In other way, I dont undertand why is the reason I always
> recieve a nil result when I use this method in the same way:
>
> $ ./script/console
> Loading development environment.
> >> article = Article.find 1
> => #<Article:0x2b5120600828 @attributes={"title"=>"Ruby on Rails",
> "id"=>"1", "content"=>"Lorem ipsum dolor sit amet, consectetuer
> adipiscing elit. Nullam tempor risus et ante. Maecenas consectetuer
> feugiat orci. Fusce vehicula velit id odio. Phasellus ut mauris. Aenean
> faucibus dolor quis nibh. Praesent convallis est id ante. In felis. "}>
>
> Ok! I put in the Article model those lines :)
>
> class Article < ActiveRecord::Base
> acts_as_ferret :fields => {
> :title=> {:store=> :yes}
> }
> end
>
> I return to console and I put the follow lines:
>
> >> index = Article.ferret_index
> => #<Ferret::Index::Index:0x2b5120574120 @writer=nil,
> @default_input_field=:id, @qp=nil,
> @dir=#<Ferret::Store::FSDirectory:0x2b51205734f0>,
> @mon_entering_queue=[], @default_field=[:title], @key=:id, @mon_count=0,
> @auto_flush=true, @open=true, @close_dir=true, @id_field=:id,
> @mon_owner=nil, @reader=nil, @searcher=nil,
> @options={:lock_retry_time=>2,
> :path=>"script/../config/../config/../index/development/article",
> :create_if_missing=>true, :default_field=>[:title],
> :analyzer=>#<Ferret::Analysis::StandardAnalyzer:0x2b5120572460>,
> :auto_flush=>true, :or_default=>false,
> :dir=>#<Ferret::Store::FSDirectory:0x2b51205734f0>, :key=>:id,
> :handle_parse_errors=>true}, @mon_waiting_queue=[]>
>
> Next, I try to evaluate the search_each method
>
> >> index.search_each("Ruby",{}) do |doc, score|
> ?> puts index[doc][:title]
> >> puts doc,score
> >> end
> nil
> 1
> 0.764464735984802
>
> Great! I recieve a score value (value), the correct id value (doc), but
> it's not possible to acquire the :title value with the
> "index[doc][:title]" expression... :( it's always returns the nil value
> :(
> So, any way to achieve it?
>
> Thanks for all!
Did you rebuild your index when you changed the title to a stored
field? I don't think this will happen automatically.
--
Dave Balmain
http://www.davebalmain.com/
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk