如何使Sphinx更松散地匹配?

I'm using the default settings in the PHP library and am using the latest version of Sphinx (2.2.3). I need to make search results match more loosely. Here are my index settings in sphinx.conf:

morphology     = stem_en
min_word_len   = 1
min_prefix_len = 1
prefix_fields = name
expand_keywords = 1

If I search for Nexus 7 on my website then a ton of search results show up (the Nexus 7 tablets and then lots of accessories for it), but if I search for ASUS New Nexus 7 FHD Tablet, Black then only the tablets show up (none of the accessories). It's like Sphinx isn't showing the accessories because they don't contain all of the keywords in the search.

How can I make Sphinx match items more "loosely" so that items that don't match exactly still show up?

Using Quorum Syntax, is the way to have control over this,

http://sphinxsearch.com/docs/current.html#extended-syntax

eg

$terms = '"'.$client->EscapeQuery($_POST['terms']).'"/0.7';

That way you can control exactly now many words are needed. - eg that 70% of the words in that example. Can change it the exact ratio to taste - or use a whole number of words ef

$terms = '"'.$client->EscapeQuery($_POST['terms']).'"/3';

requires three words.

Better than match any would allow, which would only require one word. In the example all documents even with just '7' matching would be included.


But to be clear there is no 'magic' solution, that makes perfect 'fuzzy' matching. It's always based on comprimises to make it look like the search is inteligent. You may have to do a lot of tweaking to get acceptable results - and maybe use a combination of techniques.

I'm guessing that you're using the PECL sphinx module for PHP...

You want to consider setting the setMatchMode() to SPH_MATCH_ANY.

ie.

$terms = $_POST['terms'];
$client = new SphinxClient();
$client->SetMatchMode(SPH_MATCH_ANY);
$res = $client->Query($terms, 'your_index');
...

More detail can be found here... http://php.net/manual/en/sphinxclient.setmatchmode.php