Using the current ferret gem (on Win-XP):
irb(main):001:0> require ''ferret''
c:/ruby/lib/ruby/1.8/fileutils.rb:950: warning: already initialized constant
OPT_TABLE
=> true
irb(main):002:0> include Ferret
=> Object
irb(main):003:0> index = Index::Index.new
=> #<Ferret::Index::Index:0x3477ba8 @qp=nil, ...>
irb(main):004:0> index << "This is a new doc"
=> nil
irb(main):005:0> index.search_each(''*:this'') do |d, s| puts
d end
NoMethodError: undefined method `weight'' for nil:NilClass
from
c:/ruby/lib/ruby/gems/1.8/gems/ferret-0.2.2/lib/ferret/search/index_searcher.rb:104:in
`search''
from
c:/ruby/lib/ruby/gems/1.8/gems/ferret-0.2.2/lib/ferret/index/index.rb:588:in
`do_search
''
from
c:/ruby/lib/ruby/gems/1.8/gems/ferret-0.2.2/lib/ferret/index/index.rb:291:in
`search_ea
ch''
from
c:/ruby/lib/ruby/gems/1.8/gems/ferret-0.2.2/lib/ferret/index/index.rb:290:in
`synchroni
ze''
from
c:/ruby/lib/ruby/gems/1.8/gems/ferret-0.2.2/lib/ferret/index/index.rb:290:in
`search_ea
ch''
from (irb):5
irb(main):006:0>
On 11/22/05, itsme213 <itsme213 at hotmail.com> wrote:> Using the current ferret gem (on Win-XP): > > irb(main):005:0> index.search_each(''*:this'') do |d, s| puts d end > NoMethodError: undefined method `weight'' for nil:NilClassProbably not too much help, but I can confirm the same sequence of code leads to the same exception being thrown using the 0.2.2 gem on Linux. Why is this exception thrown? On line 598 of lib/ferret/index/index.rb: query = @qp.parse(query) @qp.parse(query) is returning nil. This nil object is passed back up into Index::Index''s private do_search method. Then the nil object is passed as an argument into the searcher''s search method, where the exception is thrown. I couldn''t figure out why the QueryParser is returning a nil object from its parse() method. It looks like a bug in the racc grammar file that generates the code that parses the queries. I just installed the 0.2.2 gem, so I haven''t encountered any other errors of this nature myself. -F