Search code examples
ruby-on-railssphinxthinking-sphinx

Searching $word with Sphinx (Thinking Sphinx)


I would like to search text for words prefiexed by $.

Sample records (table with 3 rows):

This is my string containing the $word special word.
Again $word is here.
My special $word must be found.

Example RoR (thinking sphinx):

MyModel.search '$word'

I get no results but if I search for '\$word' the word is found.

How can I fix that?


Solution

  • Sphinx uses as word separators ANY character except English alphabet. This means '$' in never indexed and equivalent to a blank space. No way you can find it.

    See http://sphinxsearch.com/docs/current.html#conf-charset-table

    In your config/sphinx.yml add something like:

    charset_table: 0..9, A..Z->a..z, _, a..z, $
    

    rebuild, restart and find it !