I'm working on a sphinx (php) enabled autocomplete field that does a look up of users. I'm running into some odd situations where certain inputs which should return matches do not.
The fields in my users index are:
'fullname',
'username',
'address',
'phone',
'email'
Some general config info:
charset_type = utf-8
enable_star = 1
min_infix_len = 3
ignore_chars = U+20
My current query is set up as follows:
$search = preg_replace('/([^\s]{3,})/', '*$1*', preg_replace('/[^a-z ]/i', '', $search));
$sphinx->SetMatchMode(SPH_MATCH_EXTENDED2);
$sphinx->SetSortMode(SPH_SORT_RELEVANCE);
$matches = $sphinx->Query($search . ' @email company.com', 'users');
The issue comes with with the following search params:
John -> returns list of all Johns (GOOD!)
John S -> returns nothing (BAD!)
John St -> returns all John St*'s (GOOD!)
Similarly:
Ben -> returns all Ben's (GOOD!)
Ben M -> returns nothing (BAD!)
Ben Ma -> returns nothing (BAD!)
Ben Mar -> returns user with Ben Mar*'s (GOOD!)
Originally I thought the problem was because firstname and lastname were in different fields of the index, but now that I've merged them into the fullname field and I still get the exact same results.
Currently (via above preg_replace) I'm wrapping each word entered in *'s. I've also tried just wrapping the entire string with *,
$search = '*' . $search . '*';
but with less accurate results. I've tried the other search modes besides extended2 with no luck. (It just gets worse) I added a option to ignore spaces in the config, hoping it would pick on things like "John S" better, but still no luck.
Mostly I'd just like for people to be able to find a user by typing in First name + last initial. It's a common way people try to look up usernames, and currently they can't.
Any help is very appreciated. Thanks!
EDIT:
In much searching I found this: http://sphinxsearch.com/forum/view.html?id=5757
It seems there may be some bugs/inconsistencies in searching with spaces. But if anyone has any ideas please comment. Thanks!