Apr 17, 2011

f Comment

Fixing Issues with Sphinx Search Engine Word Forms!

Amazon How come sometimes Sphinx search engine's index does not obey the rules I put in wordforms configurations? Read on to find answers!

To give you more context Sphinx is an open-source SQL full-text search engine. Wordforms is a functionality it provides where you can specify synonyms so that your index covers them.

For example suppose your index contains documents that contain the word 't-shirt' and you also want them to be matched when the search keyword is 'tshirt'. Without setting up such synonym mapping in Sphinx, Sphinx wouldn't know 't-shirt' and 'tshirt' mean the same thing. Once you set the configuration accordingly Sphinx will get you the desired search results.

Sometimes I run into the problem where I define the mapping, rebuild Sphinx index, rerun Sphinx search daemon, but still fail to have Sphinx recognize the new mapping I put in. Why? What should I do?

Solution
If this happens to you simply insert a new line at the end of the configuration file, or reorder the mappings. For example if your original mapping is the following:

mockneck > mock neck
ae > american eagle
peacoat > pea coat
slitneck > slit neck

Reorder them to the following:

mockneck > mock neck
slitneck > slit neck
ae > american eagle
peacoat > pea coat

Rebuilt Sphinx index, rerun search daemon, and try querying your index again. Hope this helps!

By the way this fix applies to other configuration for Sphinx as well such as Stopwords. If you run into similar problems with other kinds of configuration try the same fix! Questions? Let me know!
Please leave a comment here!
One Minute Information - by Michael Wen
ADVERTISING WITH US - Direct your advertising requests to Michael