brokerexchange/elasticscout 问题修复 & 功能扩展

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

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

brokerexchange/elasticscout

Composer 安装命令:

composer require brokerexchange/elasticscout

包简介

Laravel Scout Driver for Elasticsearch 6 and 7

README 文档

README

Latest Stable Version Latest Unstable Version Total Downloads License composer.lock

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'
                         ]
                     ]
                 ]
             ],
         ],
     ];
   }

统计信息

  • 总下载量: 794
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 17
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 17
  • Watchers: 6
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-11-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固