novius/laravel-scout-elasticsearch-driver
Composer 安装命令:
composer require novius/laravel-scout-elasticsearch-driver
包简介
Elasticsearch Driver for Laravel Scout
README 文档
README
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
typefield by default according to Elasticsearch recommendations -
After a model search, an attribute
_scorewill 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:reindexa 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-mappingcommand ;elastic:migratecommand ;elastic:updatecommand ;- 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.
novius/laravel-scout-elasticsearch-driver 适用场景与选型建议
novius/laravel-scout-elasticsearch-driver 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9.96k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2020 年 01 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「search」 「elasticsearch」 「engine」 「driver」 「laravel」 「elastic」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 novius/laravel-scout-elasticsearch-driver 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 novius/laravel-scout-elasticsearch-driver 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 novius/laravel-scout-elasticsearch-driver 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel package to retrieve data from Google Search Console
Indexed Search Autocomplete - Extends the TYPO3 Core Extension Indexed_Search searchform with an autocomplete feature.
A SilverStripe module to optimise the Meta, crawling, indexing, and sharing of your website content (forked from Cyber-Duck/Silverstripe-SEO)
Abstraction Layer to index and search entities
simple api library.
A Processor for Markup written in PHP. Allows extraction of Markup into a data structure, orchestrated nested manipulation of said structure, and output as (optimized) Markup.
统计信息
- 总下载量: 9.96k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-01-08