Reputation: 9184
I have in db such data (ofcourse it is "light" version):
id | description
1 | 5W40
2 | 5W-40
and i try to use such thinking sphinx gem search query:
fields << "(@description #{params[:oiloiliness]} | #{params[:oiloiliness].gsub(/[^0-9A-Za-z]/, '')} )"
params[:oiloiliness] = "5W-40"
but for some reasons as result i see only second row... What i do wrong?
How can i search with sphinx using or operator and see in result two rows?
Upvotes: 0
Views: 528
Reputation: 16226
To be honest, I'm not entirely sure why this is happening - it's a Sphinx issue though, not Thinking Sphinx (so I've added the Sphinx tag). A work-around is to wrap both search options in double-quotes:
fields << %q{(@description "#{params[:oiloiliness]}" | "#{params[:oiloiliness].gsub(/[^0-9A-Za-z]/, '')}" )}
Also: you may want to consider adding hyphen to your list of ignore_chars via config/thinking_sphinx.yml.
Upvotes: 1