David Balmain wrote:
> On 3/13/07, Xavier Belanche <[EMAIL PROTECTED]> wrote:
>> /usr/local/lib/site_ruby/1.8/ferret/index.rb:384: [BUG] Segmentation
>> fault
>> ruby 1.8.4 (2005-12-24) [x86_64-linux]
> 
> options must be a Hash or nil, not a String. One of the things I still
> need to do with Ferret is add argument checking. At the moment, if you
> pass a string when a hash is expected you'll get a segfault or bus
> error like this. I do plan to fix this in future.
> 
> Cheers,
> Dave

Thanks David.
It's that you say: if I pass options like a Hash or nil not appears a 
bus error. 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!

-- 
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to