dev-master
9999999-devSearch any sphinx index
The Requires
- zendframework/zendframework 2.*
- php >=5.4
by Bart de Boer
search sphinx index
Wallogit.com
2017 © Pedro Peláez
Search any sphinx index
By [Bart de Boer] (http://github.com/bboer/), (*1)
When you like to search sphinx generated indexes from a zf2 application, use this module., (*2)
Preparation, (*3)
Make sure you have a working Sphinx server anywhere, (*4)
Require SphinxSearch, (*5)
From within your project execute the following:, (*6)
php composer.phar require bboer/sphinxsearch
Configure SphinxSearch, (*7)
copy sphinxsearch.local.php.dist to your /config/autoload/sphinxsearch.local.php, (*8)
Sample configuration:, (*9)
<?php
return array(
'sphinx_search' => array(
'server' => array(
'host' => 'mysphinxhost.com',
'port' => 9312,
),
),
);
Using the Search service using the ServiceTrait, (*10)
<?php
namespace MyModule\MySpace;
use Zend\ServiceManager\ServiceLocatorAwareInterface;
class MyService implements ServiceLocatorAwareInterface
{
use \SphinxSearch\ServiceManager\ServiceTrait;
public function myServiceMethod()
{
// Get the results from the SphinxSearch service
$results = $this->getSphinxSearchService()->search(
'person_main',
$filters,
$queries,
$fieldWeights,
$limit,
$offset
);
// NOTE: Used variables are not defined and intended as an example
}
}
Using the Search service by locating it through the ServiceLocator, (*11)
<?php
namespace MyModule\MySpace;
use Zend\ServiceManager\ServiceLocatorAwareInterface;
class MyService implements ServiceLocatorAwareInterface
{
use \SphinxSearch\ServiceManager\ServiceTrait;
public function myServiceMethod()
{
// Get the SphinxSearch Search service
$searchService = $this->getServiceLocator()->get(
'SphinxSearch\Search\Search'
);
// Get the results from the SphinxSearch service
$results = $searchService->search(
'person_main',
$filters,
$queries,
$fieldWeights,
$limit,
$offset
);
// NOTE: Used variables are not defined and intended as an example
}
}
Search any sphinx index
search sphinx index