yii2-extensions/elasticsearch

Elasticsearch integration and ActiveRecord for the Yii framework.

dev-main / 1.0.x-dev 2023-11-13 12:21 UTC

This package is auto-updated.

Last update: 2024-04-30 13:21:29 UTC


README

68747470733a2f2f7777772e7969696672616d65776f726b2e636f6d2f696d6167652f7969695f6c6f676f5f6c696768742e737667

Elasticsearch Query and ActiveRecord.


php-version yii2-version PHPUnit Codecov PHPStan PHPStan level Code style

This extension provides the Elasticsearch integration for the Yii framework 2.0. It includes basic querying/search support and also implements the ActiveRecord pattern that allows you to store active records in Elasticsearch.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --dev --prefer-dist yii2-extensions/elasticsearch

or add

"yii2-extensions/elasticsearch": "dev-main"

to the require section of your composer.json file.

Usage

To use this extension, you have to configure the Connection class in your application configuration:

use yii\elasticsearch\Connection;

return [
    //....
    'components' => [
        'elasticsearch' => [
            'class' => Connection::class,
            'nodes' => [
                ['http_address' => '127.0.0.1:9200'],
                // configure more hosts if you have a cluster
            ],
            'dslVersion' => 7, // default is 5
        ],
    ]
];

Configure with yiisoft/config

Add the following code to your config/config-plugin file in your application.

'config-plugin' => [
    'web' => [
        '$yii2-elasticsearch', // add this line
        'web/*.php'
    ],
],

Testing

Check the documentation testing to learn about testing.

Our social networks

Twitter

License

The MIT License. Please see License File for more information.