dev-master
9999999-dev https://github.com/liub1993/sphinxsearchLaravel package of Sphinxsearch for Laravel ^5.4
Apache-2.0
The Requires
- php >=5.3.0
- illuminate/support ~5.0
- gigablah/sphinxphp 2.0.8
by liub1993
laravel sphinx laravel 5.4 sphinxsearch
Wallogit.com
2017 © Pedro Peláez
Laravel package of Sphinxsearch for Laravel ^5.4
Simple Laravel 5.4 package for make queries to Sphinx Search., (*1)
Inspired by sngrl/sphinxsearch, and made it also usable in Laravel 5.4., (*2)
Run the following command in your console to pull down the package from packagist., (*3)
composer require cugr/sphinxsearch:dev-master
After updating composer, add the ServiceProvider to the "providers" array in config/app.php:, (*4)
'providers' => [
/*** Some others providers ***/
CuGR\SphinxSearch\SphinxSearchServiceProvider::class,
],
You can add this line to the files, where you may use SphinxSearch:, (*5)
use CuGR\SphinxSearch\SphinxSearch;
To use Sphinx Search, you need to configure your indexes and what model it should query. To do so, publish the configuration into your app., (*6)
php artisan vendor:publish --provider="CuGR\SphinxSearch\SphinxSearchServiceProvider"
This will create the file config/sphinxsearch.php. Modify as needed., (*7)
Basic query (raw sphinx results), (*8)
$sphinx = new SphinxSearch(); // or $sphinx = new SphinxSearch('connection_name');
$results = $sphinx->search('my query', 'index_name')->query();
Basic query (with Eloquent), (*9)
$results = $sphinx->search('my query', 'index_name')->get();
Query another Sphinx index with limit and filters., (*10)
$results = $sphinx->search('my query', 'index_name')
->limit(30)
->filter('attribute', array(1, 2))
->range('int_attribute', 1, 10)
->get();
Query with match and sort type specified., (*11)
$result = $sphinx->search('my query', 'index_name')
->setFieldWeights(
array(
'partno' => 10,
'name' => 8,
'details' => 1
)
)
->setMatchMode(\Sphinx\SphinxClient::SPH_MATCH_EXTENDED)
->setSortMode(\Sphinx\SphinxClient::SPH_SORT_EXTENDED, "@weight DESC")
->get(true); //passing true causes get() to respect returned sort order
CuGR Sphinx Search is open-sourced software licensed under the MIT license, (*12)
Laravel package of Sphinxsearch for Laravel ^5.4
Apache-2.0
laravel sphinx laravel 5.4 sphinxsearch