novius/laravel-scout-elasticsearch-driver 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

novius/laravel-scout-elasticsearch-driver

最新稳定版本:5.0.1

Composer 安装命令:

composer require novius/laravel-scout-elasticsearch-driver

包简介

Elasticsearch Driver for Laravel Scout

README 文档

README

Novius CI Packagist Release Licence

This package is an adaptation of babenkoivan/scout-elasticsearch-driver to get working with Elasticsearch >= 7.0.0

This package version was created to be compatible with Elasticsearch "Removal of mapping types" introduced in Elasticsearch >= 7.0.0

Features added

  • Model's type is now saved in type field by default according to Elasticsearch recommendations

  • After a model search, an attribute _score will be hydrated on your result Model.

Example :

$results = MyModel::search('keywords')->get();
foreach ($results as $result) {
    // Score is now available in : $result->_score
}
  • Logs : you can now use Laravel loggers to log ElasticSearch's requests

To enable logs you have to set SCOUT_ELASTIC_LOG_ENABLED to true and specify which log's channel(s) to use.

Example :

config/logging.php

<?php

return [

    ...
    
    'channels' => [

        ...

        'es' => [
            'driver' => 'daily',
            'path' => storage_path('logs/es.log'),
            'level' => 'debug',
            'days' => 5,
        ],
    ],
];
  • elastic:reindex a new command to build and populate a new index with 0 downtime ;

config/scout_elastic.php

<?php

return [
    'client' => [
        'hosts' => [
            env('SCOUT_ELASTIC_HOST', 'localhost:9200'),
        ],
    ],
    'document_refresh' => env('SCOUT_ELASTIC_DOCUMENT_REFRESH'),
    'searchable_models' => [],
    'log_enabled' => env('SCOUT_ELASTIC_LOG_ENABLED', false),
    'log_channels' => [],
];

Features deleted from original package

  • elastic:update-mapping command ;
  • elastic:migrate command ;
  • elastic:update command ;
  • Mapping of models : replaced by getDefaultMapping() of index configurator ;
  • Single indexer ;

Requirements

  • PHP >= 7.4
  • Laravel Framework >= 7.25
  • Elasticsearch >= 7.0.0

For Laravel > 6 and < 7.25 you can install 2.x version.

Installation

composer require novius/laravel-scout-elasticsearch-driver:dev-master

Configuration

To configure the package you need to publish settings first:

php artisan vendor:publish --provider="Laravel\Scout\ScoutServiceProvider"
php artisan vendor:publish --provider="Novius\ScoutElastic\ScoutElasticServiceProvider"

Then, set the driver setting to elastic in the config/scout.php file and configure the driver itself in the config/scout_elastic.php file. The available options are:

Option Description
client A setting hash to build Elasticsearch client. More information you can find here. By default the host is set to localhost:9200.
document_refresh This option controls when updated documents appear in the search results. Can be set to 'true', 'false', 'wait_for' or null. More details about this option you can find here. By default set to null.

Note, that if you use the bulk document indexing you'll probably want to change the chunk size, you can do that in the config/scout.php file.

Usage

Please read the original package documentation.

Lint

Run php-cs with:

composer run-script lint

Contributing

Contributions are welcome! Leave an issue on Github, or create a Pull Request.

Licence

This package is under MIT Licence.

统计信息

  • 总下载量: 9.81k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 3
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-01-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固