Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I identify matched terms when searching with sphinx?

I am using sphinx to do full text search on a mysql database through thinking sphinx.

I would like to highlight the matched terms in the results I show to the user.

Shpinx is smart enough that searching for 'botulism' will match "i like to inject botulinum into my eyes"

How can I get it to tell me that 'botulinum' matches 'botulism'?


1 Answers

First, I'm heavily using sphinx for one of my project but I'm not using ThinkingSphinx since the config file we use is quite complex, I'm using a customized act_as_sphinx plugin.

To answer your question from pure sphinx point of view :

  • there is an a BuildExcerpts api in sphinx to get excerpt of a content with matching underlined see http://www.sphinxsearch.com/docs/current.html#api-func-buildexcerpts.
    Thinking Sphinx should provide this functionnality

  • to match botulism as botulinum you should compile sphinx with stemmer, maybe the porter algorithm may answer your question : see http://www.sphinxsearch.com/docs/current.html#conf-morphology

Hope this helps and I highly encourage you to look at the sphinx documentation to fully use this very efficient indexer

Manfred

like image 57
Manfred Dardenne Avatar answered Nov 21 '25 08:11

Manfred Dardenne



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!