Hi,

I found a problem (and a hackaround solution) with the global search in 
Thinking Sphinx.

When I try to use ThinkingSphinx.search(term), I get a traceback like the 
following:

NoMethodError: undefined method `constantize' for 0:Fixnum
        from lib/thinking_sphinx/search.rb:936:in `class_from_crc'
        from lib/thinking_sphinx/search.rb:915:in `instances_from_matches'
        from lib/active_support/ordered_hash.rb:139:in `each'
        from lib/active_support/ordered_hash.rb:139:in `each'
        from lib/thinking_sphinx/search.rb:913:in `instances_from_matches'
        from lib/thinking_sphinx/search.rb:436:in `compose_results'
        [etc.]
(I cleaned up the pathnames a bit)

My (relevant) environment:
  * rails (3.0.9)
  * riddle (1.4.0)
  * thinking-sphinx (2.0.5 dc98d80)
  * sphinx (2.0.1-beta)

I've managed to locate the problem: there are a couple of Sphinx version 
number comparisons in ThinkingSphinx::Search, which choose what to do based 
on the Sphinx version number. For some reason the correct actions would be 
the ones chosen for Sphinx versions < 2, even though I'm running Sphinx 
2.0.1.

I can get the search to run correctly with the following monkey-patch:
class ThinkingSphinx::Search
 def class_from_crc(crc)
  # if Riddle.loaded_version.to_i < 2
   config.models_by_crc[crc].constantize
  # else
  #  crc.constantize
  # end
 end
 def crc_attribute
  # Riddle.loaded_version.to_i < 2 ? 'class_crc' : 'sphinx_internal_class'
  'class_crc'
 end
end

Does anybody have an idea of why this is? Does Thinking Sphinx make 
incorrect assumptions about the column names returned by sphinx, or do I 
have a configuration error somewhere?

- Timo Virkkala

-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/thinking-sphinx/-/g5JBaJp8TV4J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/thinking-sphinx?hl=en.

Reply via email to