Including partial word matches in Sphinx?

I am new to Sphinx and trying to configure it correctly. I want to allow partial word matching for all searches, and I don’t want users to enter wildcards on their own.

I want the search to work either on Amazon or Google, where if you start typing, sentences will come. So, for example, if someone typed β€œx,” then characters like β€œXbox” should appear.

Here are the index settings that I currently have:

min_word_len = 1 min_prefix_len = 1 prefix_fields = name charset_type = utf-8 

On the PHP side, I use SPH_MATCH_EXTENDED2 and SPH_SORT_RELEVANCE . I left the default ranking mode, whatever that is. These settings seemed to provide the best search results when I changed the settings based on trial and error.

I read similar questions here and on other sites, but the answers always seem to refer to enable_star , which the documentation says is not recommended.

So my question is: how do I enable partial word matches in Sphinx? Should I just add * to each word in a user request, doing something like this?

 $search = str_replace(' ', '* ', trim($search)) + '*'; 
+6
source share
1 answer

You can set expand_keywords = 1 as described in the docs .

In fact, it simply adds stars to you automatically - in such a way that overall exact matches will be ranked a bit higher than pure "part" matches.

+6
source

Source: https://habr.com/ru/post/971289/


All Articles