sngrl / sphinxsearch

Sphinx Search for Laravel 5
MIT License
124 stars 89 forks source link

Set indexer name method #39

Open adriaroca opened 6 years ago

adriaroca commented 6 years ago

I create a new method to set the index name, specialy when the devoloper don't need the 'search' method, only 'query'.

In 'query' method, SphinxSearch use the first indexer specified in the configuration file. With this method, the developer can specify the indexer that is needed.

Example:

$sphinx = new SphinxSearch();
$sphinx->setMatchMode(\Sphinx\SphinxClient::SPH_MATCH_FULLSCAN);
$sphinx->setFilterFloatRange('@geodist', 0.0, $circle);
$sphinx->setSortMode(SphinxClient::SPH_SORT_ATTR_ASC, '@geodist');
$sphinx->setGeoAnchor('lat', 'lng', $lat, $lng);
$sphinx->limit(5000);
$sphinx->setIndexName('insurance_centers');
$results = $sphinx->query();