brokerexchange/elasticscout
Composer 安装命令:
composer require brokerexchange/elasticscout
包简介
Laravel Scout Driver for Elasticsearch 6 and 7
README 文档
README
ElasticScout
A Laravel Scout Driver for Elasticsearch 6
Overview
ElasticScout is a Laravel Scout Elasticsearch 6 compatible engine. It makes critical changes to the old Elasticseach Scout Engine, as well as adds new functionality.
The ElasticScout engine includes an Elasticsearch Query Builder which can be used to create elaborate custom queries and aggregations, allowing full use of Elasticsearch within the Laravel/Scout Paradigm.
License
ElasticScout is released under the MIT Open Source License, https://opensource.org/licenses/MIT
Copyright
ElasticScout © Broker Exchange Network 2018
Installation
- Run composer require command
composer require brokerexchange/elasticscout - Configure Elasticsearch Host (default: localhost:9200)
ELASTICSEARCH_HOST='elastic1.host.com:9200,elastic2.host.com:9200'
- Add trait to desired model
use ElasticScout\Searchable;
Usage
//create search/query object $search = $article->search() ->boolean() ->should(DSL::match('title',$request->input('query'))) ->should(DSL::match('body',$request->input('query'))) ->highlight(['body','title']) ->filter(DSL::term('published', 1)) ->aggregate(Agg::terms('categories', 'category.name')); //fire the search $articles = $search->paginate(); //retrieve aggregation results $categories = $search->aggregation('categories'); //retrieve highlight results for title field of first result article $firstArticleTitleHighlights = $articles->first()->highlight('title');
Mappings
You may set a custom mapping by simply defining a "mapping" method on your model.
public function mappings() { return [ $this->searchableType() => [ 'properties' => [ 'name' => [ 'type' => 'text', 'fields' => [ 'keyword' => [ 'type' => 'keyword', ], 'autocomplete' => [ 'type' => 'text', 'analyzer' => 'autocomplete', 'search_analyzer' => 'autocomplete_search', ], ], ], ] ] ] }
Settings
You may create custom settings and analyzers by creating a "settings" method on the model.
public function settings() { return [ 'index' => [ 'analysis' => [ 'analyzer' => [ 'autocomplete' => [ 'tokenizer' => 'autocomplete', 'filter' => [ 'lowercase', ], ], 'autocomplete_search' => [ 'tokenizer' => 'lowercase', ], ], 'tokenizer' => [ 'autocomplete' => [ 'type' => 'edge_ngram', 'min_gram' => 1, 'max_gram' => 15, 'token_chars' => [ 'letter' ] ] ] ], ], ]; }
brokerexchange/elasticscout 适用场景与选型建议
brokerexchange/elasticscout 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 794 次下载、GitHub Stars 达 17, 最近一次更新时间为 2016 年 11 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「search」 「elasticsearch」 「laravel」 「scout」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 brokerexchange/elasticscout 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 brokerexchange/elasticscout 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 brokerexchange/elasticscout 相关的其它包
同方向 / 同关键字的高下载量 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.
Abstraction Layer to index and search entities
simple api library.
Pimcore 10.x Website Indexer (powered by Zend Search Lucene)
Symfony bundle for Elasticsearch integration with round-robin load balancing
统计信息
- 总下载量: 794
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 17
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-11-03