himiklab/yii2-search-component-v2
最新稳定版本:2.0.7
Composer 安装命令:
composer require himiklab/yii2-search-component-v2
包简介
Yii2 Zend Lucene search component v2
README 文档
README
Zend Lucene search component for Yii2.
Installation
The preferred way to install this extension is through composer.
- Add
"himiklab/yii2-search-component-v2" : "*", "zendframework/zendsearch": "2.0.0rc6"
to the require section of your application's composer.json file.
- Add a new component in
componentssection of your application's configuration file, for example:
'components' => [ 'search' => [ 'class' => 'himiklab\yii2\search\Search', 'models' => [ 'app\modules\page\models\Page', ], ], // ... ],
- Add behavior in the AR models, for example:
use himiklab\yii2\search\behaviors\SearchBehavior; public function behaviors() { return [ 'search' => [ 'class' => SearchBehavior::className(), 'searchScope' => function ($model) { /** @var \yii\db\ActiveQuery $model */ $model->select(['title', 'body', 'url']); $model->andWhere(['indexed' => true]); }, 'searchFields' => function ($model) { /** @var self $model */ return [ ['name' => 'title', 'value' => $model->title], ['name' => 'body', 'value' => strip_tags($model->body)], ['name' => 'url', 'value' => $model->url, 'type' => SearchBehavior::FIELD_KEYWORD], ['name' => 'model', 'value' => 'page', 'type' => SearchBehavior::FIELD_UNSTORED], ]; } ], ]; }
Usage
See example Search module in samples directory.
Resources
统计信息
- 总下载量: 18.74k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 27
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-12-04