im trying to write a sphinx query to list domains that start with a certain keyword.
Say I have a sphinx index with the following items.
stack.com
stack-it.com
stack.net
stack-studio.com
stackoverflow.com
stackmonkey.com
The following query
$cl->SetMatchMode ( SPH_MATCH_EXTENDED2 );
$cl->SetFieldWeights ( array ( "site_domain"=>100 ) );
$cl->SetSortMode ( SPH_SORT_EXTENDED , "@weight DESC" );
$cl->SetLimits(0, 100);
$cl->AddQuery( '^stack', "domainsDb" );
Will only list:
stack.com
stack-it.com
stack.net
stack-studio.com
As it finds results that end in a . or -. But stackoverflow.com is not shown, as it’s not a full match I guess? How can I get ALL results that start with ‘query’ to show? Even if it’s part of a word.
You should enanble star option (http://sphinxsearch.com/docs/1.10/conf-enable-star.html) and add * after keyword you are looking for:
$cl->AddQuery( ‘^stack*, “domainsDb” );
Also dont forget to setup minimal infix length (http://sphinxsearch.com/docs/1.10/conf-min-infix-len.html)
Using MySQL for full text searching is not really a recommended idea.
1) Fulltext searching with FT indexes is slow compared to sphinx/solr
2) Fulltext search without FT indexes is very very slow and can utilize 100% of your DB server very quilckly and render it unusable even at very very low traffic
3) To be able to have FT indexes you must use MyISAM engine, not Innodb which on other hand can have some drawbacks of its own