bboer / sphinxsearch
此包的最新版本(dev-master)没有可用的许可信息。
搜索任何sphinx索引
dev-master
2013-10-10 12:43 UTC
Requires
- php: >=5.4
- zendframework/zendframework: 2.*
This package is not auto-updated.
Last update: 2024-09-24 02:18:47 UTC
README
由[Bart de Boer] (http://github.com/bboer/)
简介
当你想从zf2应用程序中搜索sphinx生成的索引时,请使用此模块。
安装
-
准备
确保你任何地方都有可用的Sphinx服务器
-
需要SphinxSearch
在项目内部执行以下操作
php composer.phar require bboer/sphinxsearch -
配置SphinxSearch
将sphinxsearch.local.php.dist复制到你的/config/autoload/sphinxsearch.local.php
示例配置
<?php return array( 'sphinx_search' => array( 'server' => array( 'host' => 'mysphinxhost.com', 'port' => 9312, ), ), );
用法
-
使用ServiceTrait通过搜索服务
<?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 } }
-
通过ServiceLocator定位使用搜索服务
<?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 } }