2017 © Pedro Peláez
 

yii2-extension yii2-search-component-v2

Yii2 Zend Lucene search component v2

image

himiklab/yii2-search-component-v2

Yii2 Zend Lucene search component v2

  • Tuesday, February 27, 2018
  • by HimikLab
  • Repository
  • 4 Watchers
  • 22 Stars
  • 2,814 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 7 Forks
  • 2 Open issues
  • 4 Versions
  • 12 % Grown

The README.md

Yii2 Zend Lucene Search Component V2

Zend Lucene search component for Yii2., (*1)

Packagist Packagist license, (*2)

Installation

The preferred way to install this extension is through composer., (*3)

  • Add
"himiklab/yii2-search-component-v2" : "*",
"zendframework/zendsearch": "2.0.0rc6"

to the require section of your application's composer.json file., (*4)

  • 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., (*5)

Resources

The Versions

27/02 2018

dev-master

9999999-dev

Yii2 Zend Lucene search component v2

  Sources   Download

MIT

The Requires

 

yii2 search lucene

02/11 2017

2.0.5

2.0.5.0

Yii2 Zend Lucene search component v2

  Sources   Download

MIT

The Requires

 

yii2 search lucene

07/11 2016

2.0.4

2.0.4.0

Yii2 Zend Lucene search component v2

  Sources   Download

MIT

The Requires

 

yii2 search lucene

02/02 2016

2.0.3

2.0.3.0

Yii2 Zend Lucene search component v2

  Sources   Download

MIT

The Requires

 

yii2 search lucene