定制 diezeel/laravel-scout-sphinx 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

diezeel/laravel-scout-sphinx

Composer 安装命令:

composer require diezeel/laravel-scout-sphinx

包简介

Laravel Scout Sphinx Driver

README 文档

README

THIS IS MY PERSONAL VERSION FOR MY PROJECT! DESCRIPTION MAYBE UPDATED LATER

Build Status Latest Version on Packagist Software License

Introduction

This package offers advanced functionality for searching and filtering data using Sphinx search engine for Laravel Scout.

Installation

Composer

Use the following command to install package via composer

composer require constantable/laravel-scout-sphinx

Configuration

Publish the Scout configuration using the vendor:publish Artisan command.

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

This command will publish the scout.php configuration file to your config directory. Edit this file to set 'sphinxsearch' as a Scout driver:

'driver' => env('SCOUT_DRIVER', 'sphinxsearch'),

And add default Sphinx connection options

    'sphinxsearch' => [
        'host' => env('SPHINX_HOST', 'localhost'),
        'port' => env('SPHINX_PORT', '9306'),
        'socket' => env('SPHINX_SOCKET'),
        'charset' => env('SPHINX_CHARSET'),
    ],

Override these variables in your .env file if need

Usage

  • Add the Laravel\Scout\Searchable trait to the model you would like to make searchable.
  • Customize index name and searchable data for the model:
    public function searchableAs()
    {
        return 'posts_index';
    }
    
    public function toSearchableArray()
    {
        $array = $this->toArray();

        // Customize array...

        return $array;
    }

The basic search:

$orders = App\Order::search('Star Trek')->get();

Please refer to the Scout documentation for additional information. You can run more complex queries on index using callback, set the where clause, orderBy or paginate, for example:

$oorders = App\Order::search($keyword, function (SphinxQL $query) {
        return $query->groupBy('description');
    })            
    ->where('status', 1)
    ->orderBy('date', 'DESC')
    ->paginate(20);

Note: Changes on Sphinx indexes are only allowed for RT (Real Time) indexes. If you have ones and you need to update/delete records please define public $isRT = true; model's property.

Credits

License

Licensed under the MIT license

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 25
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-11-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固