2017 © Pedro Peláez
 

library sphinx-search

Simple handler to query sphinx search

image

rikiless/sphinx-search

Simple handler to query sphinx search

  • Monday, April 23, 2018
  • by rikiless
  • Repository
  • 1 Watchers
  • 1 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Sphinx Search

Handler for Sphinx API Client. It contains most used functions to setup field weights, filter, sorting and multi-quering., (*1)

Tested on Sphinx Server 2.1.9 / 2.2.4 and sphinx PECL package 1.3.2., (*2)

Requirements

This package requires PHP 5.4., (*3)

Installation

The best way to install this package is using Composer, (*4)

$ composer require "rikiless/sphinx-search:@dev"

Nette Framework

If you are using Nette Framework you can simply register service:, (*5)

sphinx:
        host: localhost
        port: 9312

services:
    - Rikiless\Sphinx\Search(%sphinx%)

In presenter:, (*6)

class Presenter ...
{

    /** @var Rikiless\Sphinx\Search @inject */
    public $fulltextSearch;

}

Use

Examples

Simple query:, (*7)

$fulltext = new Rikiless\Sphinx\Search([
    'host' => 'localhost',
    'port' => 9312
]);

try {
    /** @var Rikiless\Sphinx\Data $results */
    $results = $fulltext->query('search something');
    var_dump($results->getMatchesList());

} catch (Rikiless\Sphinx\Exception $e) {
    print $e->getMessage();
}

Multiple queries with basic setup:, (*8)

$search = 'search something';

$this->fulltextSearch->setIndex('myindex');
$this->fulltextSearch->setLogComment(sprintf('Fulltext query on %s', $this->domain));
$this->fulltextSearch->setFieldWeights([
    'name' => 10,
    'content' => 5,
    'subject_name' => 3,
    'city' => 2,
    'contact_person' => 2
]);

$this->fulltextSearch->resetFilters();
$this->fulltextSearch->setFilterRange('position', 0, 19999999);
$this->fulltextSearch->addQuery($search);

$this->fulltextSearch->resetFilters();
$this->fulltextSearch->setFilterRange('position', 20000000, 29999999);
$this->fulltextSearch->addQuery($search);

try {
    $results = $this->fulltextSearch->runQueries();
} catch (Rikiless\Sphinx\Exception $e) {
    print $e->getMessage();
}

foreach ($results as $row) {
    /** @var Rikiless\Sphinx\Data $row */
    var_dump($row->getMatches());
}

Sources

  • http://sphinxsearch.com
  • http://php.net/manual/en/book.sphinx.php
  • http://sphinxsearch.com/wiki/doku.php?id=php_api_docs
  • http://pecl.php.net/package/sphinx

The Versions

23/04 2018

dev-master

9999999-dev

Simple handler to query sphinx search

  Sources   Download

MIT

The Requires

  • php >=5.4

 

api search nette sphinx fulltext

06/10 2014

0.9.4

0.9.4.0

Simple handler to query sphinx search

  Sources   Download

MIT

The Requires

  • php >=5.4
  • sphinx-search/client *

 

api search nette sphinx fulltext

30/09 2014

0.9.3

0.9.3.0

Simple handler to query sphinx search

  Sources   Download

MIT

The Requires

  • php >=5.4
  • sphinx-search/client *

 

api search nette sphinx fulltext

24/09 2014

0.9.2

0.9.2.0

Simple handler to query sphinx search

  Sources   Download

MIT

The Requires

  • php >=5.4
  • sphinx-search/client *

 

api search nette sphinx fulltext

24/09 2014

0.9.1

0.9.1.0

Simple handler to query sphinx search

  Sources   Download

MIT

The Requires

  • php >=5.4
  • sphinx-search/client *

 

api search nette sphinx fulltext

23/09 2014

0.9.0

0.9.0.0

Simple handler to query sphinx search

  Sources   Download

MIT

The Requires

  • php >=5.4
  • sphinx-search/client *

 

api search nette sphinx fulltext