PHPackages                             shopwwi/webman-scout - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. shopwwi/webman-scout

ActiveLibrary[Search &amp; Filtering](/categories/search)

shopwwi/webman-scout
====================

webman Scout provides a driver based solution to searching your Eloquent models.

v1.1.3(3y ago)9163MITPHPPHP &gt;=7.3|^8.0

Since Jun 1Pushed 3y agoCompare

[ Source](https://github.com/shopwwi/webman-scout)[ Packagist](https://packagist.org/packages/shopwwi/webman-scout)[ RSS](/packages/shopwwi-webman-scout/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (7)Versions (6)Used By (0)

[!['Build Status'](https://camo.githubusercontent.com/b593d6e080c2a146ec502e031af00098ea5cb4fa45ee7a7b9e32554b6e773598/68747470733a2f2f7472617669732d63692e6f72672f73686f707777692f7765626d616e2d73636f75742e7376673f6272616e63683d6d61696e)](https://github.com/shopwwi/webman-scout) [!['Latest Stable Version'](https://camo.githubusercontent.com/fa404ccef880f8764e5f16e442749b33b56a6cc0d5838cf407b236ae1e4f98ca/68747470733a2f2f706f7365722e707567782e6f72672f73686f707777692f7765626d616e2d73636f75742f762f737461626c652e737667)](https://packagist.org/packages/shopwwi/webman-scout) [!['Total Downloads'](https://camo.githubusercontent.com/9b16f8016bb66023b80fbe4bcbd9a4afc752297829ab0f564498681771935043/68747470733a2f2f706f7365722e707567782e6f72672f73686f707777692f7765626d616e2d73636f75742f642f746f74616c2e737667)](https://packagist.org/packages/shopwwi/webman-scout) [!['License'](https://camo.githubusercontent.com/977ba0a22678f690e9d1207a129f567d63e062ce1ac00128ad4a0755c3969640/68747470733a2f2f706f7365722e707567782e6f72672f73686f707777692f7765626d616e2d73636f75742f6c6963656e73652e737667)](https://packagist.org/packages/shopwwi/webman-scout)

安装
==

[](#安装)

```
composer require shopwwi/webman-scout

```

- 如果觉得方便了你 不要吝啬你的小星星哦 tycoonSong
- 不适用于非 laravel orm
- 此插件源于laravel/scout 感谢伟大的开源付出

使用方法
----

[](#使用方法)

### 设置

[](#设置)

当使用 `xunsearch` 时，需提前在config/plugin/shopwwi/scout/ini下创建「indexName」.ini文件，亦可指定ini文件夹路径

```
// 路径config/plugin/shopwwi/scout

    'driver' => 'meilisearch', // 支持"algolia", "meilisearch","elasticsearch", "database", "collection", "null","xunsearch"
    'queue' => false, // 队列默认关闭 开启队列请先安装composer require webman/redis-queue
    'xunsearch' => [
        'path' => config_path().'/plugin/shopwwi/scout/ini/'
    ]

```

### 搜索驱动安装

[](#搜索驱动安装)

- algolia

```
composer require algolia/algoliasearch-client-php

```

- xunsearch

```
composer require hightman/xunsearch

```

- meilisearch

```
composer require meilisearch/meilisearch-php

```

- elasticsearch

```
composer require elasticsearch/elasticsearch

```

### 命令行

[](#命令行)

- 创建index 一般无需操作 elasticsearch需要

```
php webman scout:index 'goods'

```

- 删除index 如非model设定 一般为表名

```
php webman scout:delete-index 'goods'

```

- 初始数据model导入 --chunk导入批次数量 不宜设置过大哦

```
php webman scout:import 'app\model\Goods' --chunk=200

```

- 重置清空模型数据

```
php webman scout:flush 'app\model\Goods'

```

### 配置模型索引

[](#配置模型索引)

每个 Eloquent 模型都与给定的搜索 「索引」同步，该索引包含该模型的所有可搜索记录。 换句话说，你可以将每个索引视为一个 MySQL 表。 默认情况下，每个模型都将持久化到与模型的典型 「表」名称匹配的索引。 通常，是模型名称的复数形式； 但你可以通过重写模型上的 `searchableAs` 方法来自由地自定义模型的索引：

```
