PHP code example of dariusiii / sphinxsearch

1. Go to this page and download the library: Download dariusiii/sphinxsearch library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dariusiii / sphinxsearch example snippets


	"       /*** Some others packages ***/
		"dariusiii/sphinxsearch": "^1.0",
	},

composer 

	'providers' => array(
        /*** Some others providers ***/
        dariusiii\SphinxSearch\SphinxSearchServiceProvider::class,
    ),

use dariusiii\SphinxSearch\SphinxSearch;

php artisan vendor:publish

return array (
	'host'    => '127.0.0.1',
	'port'    => 9312,
	'indexes' => array (
		'my_index_name' => array ( 'table' => 'my_keywords_table', 'column' => 'id' ),
	)
);

return array (
	'host'    => '127.0.0.1',
	'port'    => 9312,
	'indexes' => array (
		'my_index_name' => FALSE,
	)
);

$sphinx = new SphinxSearch();
$results = $sphinx->search('my query', 'index_name')->query();

$results = $sphinx->search('my query', 'index_name')->get();

$results = $sphinx->search('my query', 'index_name')
	->limit(30)
	->filter('attribute', array(1, 2))
	->range('int_attribute', 1, 10)
	->get();

$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