rystlee/laravel-scout-elasticsearch
Composer 安装命令:
composer require rystlee/laravel-scout-elasticsearch
包简介
ElasticSearch Driver For Laravel Scout
README 文档
README
This package is the Elasticsearch driver for Laravel Scout.
Installation
composer require rystlee/laravel-scout-elasticsearch
Setting up Elasticsearch configuration
You must have a Elasticsearch server up and running with the index you want to use created
If you need help with this please refer to the Elasticsearch documentation
After you've published the Laravel Scout package configuration:
// config/scout.php // Set your driver to elasticsearch 'driver' => env('SCOUT_DRIVER', 'elasticsearch'), ... 'elasticsearch' => [ 'index' => env('ELASTICSEARCH_INDEX', 'laravel'), 'hosts' => [ env('ELASTICSEARCH_HOST', 'http://localhost'), ], ], ...
Highlight Usage
- Use
RystLee\LaravelScoutElastic\Traits\EsSearchablein the model that needs highlight search results. Then the collection results will contains highlight attribute which has highlight hits relevant to the scout settingtoSearchableArray. - Foreach the highlight's results in your view like the following example:
@if(isset($post->highlight['body'])) @foreach($post->highlight['body'] as $item) ......{!! $item !!}...... @endforeach @else {{ mb_substr($post->content, 0, 150) }}...... @endif
Usage
Now you can use Laravel Scout as described in the [official documentation](https://laravel.com/docs/5.3/scout
License
The MIT License (MIT).
统计信息
- 总下载量: 16
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2017-11-30