yii2-search-component-v2

  • 所有者: himiklab/yii2-search-component-v2
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

Yii2 Zend Lucene Search Component V2

Zend Lucene search component for Yii2.

Packagist Packagist license

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 components section 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

主要指標

概覽
名稱與所有者himiklab/yii2-search-component-v2
主編程語言PHP
編程語言PHP (語言數: 1)
平台
許可證MIT License
所有者活动
創建於2014-12-03 15:55:26
推送於2019-05-23 06:50:36
最后一次提交2019-05-18 12:23:15
發布數5
最新版本名稱2.0.7 (發布於 )
第一版名稱2.0.3 (發布於 )
用户参与
星數25
關注者數4
派生數8
提交數15
已啟用問題?
問題數0
打開的問題數0
拉請求數0
打開的拉請求數0
關閉的拉請求數1
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?