1

Similar Stack Overflow Question

I want users to be able to search through my thinking_sphinx text box a word like wood and have it pull up Wooden and Woodworking. This words fine if the user types in wood*, but if they type in just wood with no * then no results are shown. If there a way to get the results of wood* without having to type in the asterisk. Most users aren't that smart.

Community
  • 1
  • 1
Mike
  • 1,190
  • 5
  • 13
  • 26

3 Answers3

2

can you append an asterisk at the end of user data before sending it to search?

Ben Hughes
  • 14,075
  • 1
  • 41
  • 34
  • 1
    @businesses = Business.search(params[:search] + '*') works well. You can also do @businesses = Business.search('*' + params[:search] + '*') and that way no matter where in the word it is, it will find it. Thanks! – Mike Jul 10 '09 at 20:05
1

I think you could get what you're trying to achieve with wordforms in your sphinx configuration. See the documentation here: http://sphinxsearch.com/docs/current.html#conf-wordforms.

You can utilize more advanced Sphinx configuration with a sphinx.yml file. See the following: http://freelancing-god.github.com/ts/en/advanced_config.html

Ben Crouse
  • 8,290
  • 5
  • 35
  • 50
1

just pass :star => true along ;)