mongosoft/yii2-xmlpipe
最新稳定版本:0.1.1
Composer 安装命令:
composer require mongosoft/yii2-xmlpipe
包简介
Sphinx XmlPipe Extension for Yii 2
README 文档
README
This extension provides an easy way to create xmlpipe2 data source for the Sphinx search engine.
Installation
The preferred way to install this extension is through composer.
Either run
composer require --prefer-dist mongosoft/yii2-xmlpipe "*"
or add
"mongosoft/yii2-xmlpipe": "*"
to the require section of your composer.json file.
Usage
XmlPipe document
<?php namespace app\models; use mongosoft\xmlpipe\BaseXmlPipe; class XmlPipeDocument extends BaseXmlPipe { /** * @inheritdoc */ public function fields() { return [ 'name', 'description', ]; } /** * @inheritdoc */ public function attributes() { return [ ['name' => 'type', 'type' => 'int', 'bits' => 16], ['name' => 'name', 'type' => 'string'], ['name' => 'description', 'type' => 'string'], ]; } /** * @inheritdoc */ public function addDocuments() { $query = Items::find() ->select(['type', 'full_name', 'description']) ->asArray(); foreach ($query->each() as $item) { $this->pushDocument([ 'type' => $item['type'], 'name' => $item['full_name'], 'description' => $item['description'], ]); } } }
Controller
<?php namespace app\controllers; use yii\web\Controller; class TestController extends Controller { /** * @inheritdoc */ public function actions() { return [ 'xmlpipe' => [ 'class' => 'mongosoft\xmlpipe\Action', 'document' => 'app\models\XmlPipeDocument', ], ]; } }
Sphinx config
Add the following lines to the configuration file (sphinx.conf)
source myindex
{
type = xmlpipe2
xmlpipe_command = curl http://localhost/test/xmlpipe
}
index myindex
{
source = myindex
path = /var/path/to/index/myindex
docinfo = extern
morphology = lemmatize_ru
charset_type = utf-8
}
统计信息
- 总下载量: 12.03k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2015-04-09