PHP code example of ms / sphinx-bundle

1. Go to this page and download the library: Download ms/sphinx-bundle 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/ */

    

ms / sphinx-bundle example snippets

 php
$indexesToSearch = array('Items');
$sphinxSearch = $this->get('sphinx.search');
$searchResults = $sphinxSearch->search('search query', $indexesToSearch);
 php
$indexesToSearch = array('Items');
$options = array(
  'result_offset' => 0,
  'result_limit' => 25,
  'field_weights' => array(
    'Name' => 2,
    'SKU' => 3,
  ),
);
$sphinxSearch = $this->get('sphinx.search');
$sphinxSearch->setMatchMode(SPH_MATCH_EXTENDED2);
$sphinxSearch->setFilter('disabled', array(1), true);
$searchResults = $sphinxSearch->search('search query', $indexesToSearch, $options);