sphinx/client

dev-master 2016-04-05 14:48 UTC

This package is auto-updated.

Last update: 2024-04-15 18:33:17 UTC


README

See this bug report for more info.

Latest Stable Version Total Downloads Latest Unstable Version Build Status Code Coverage Scrutinizer Code Quality SensioLabsInsight License

Sphinx PHP client

Copy / paste from sphinxsearch/sphinx

Installation

Add the following to the require section of your composer.json file:

"sphinx/client": "dev-master"

Usage

Search test word in Sphinx for example_idx index.

use Sphinx\Client;

$sphinx = new Client();
$sphinx->setServer('localhost', 6712);
$sphinx->setMatchMode(Client::MATCH_ANY);
$sphinx->setMaxQueryTime(3);

$result = $sphinx->query('test', 'example_idx');

var_dump($result);

Printed result:

array(10) {
  ["error"]=>
  string(0) ""
  ["warning"]=>
  string(0) ""
  ["status"]=>
  int(0)
  ["fields"]=>
  array(3) {
    [0]=>
    string(7) "subject"
    [1]=>
    string(4) "body"
    [2]=>
    string(6) "author"
  }
  ["attrs"]=>
  array(0) {
  }
  ["matches"]=>
  array(1) {
    [3]=>
    array(2) {
      ["weight"]=>
      int(1)
      ["attrs"]=>
      array(0) {
      }
    }
  }
  ["total"]=>
  int(1)
  ["total_found"]=>
  int(1)
  ["time"]=>
  float(0)
  ["words"]=>
  array(1) {
    ["to"]=>
    array(2) {
      ["docs"]=>
      int(1)
      ["hits"]=>
      int(1)
    }
  }
}

License

This bundle is under the GPL-3.0 license. See the complete license in the file: LICENSE