PHPackages                             flex/xunsearch-laravel - 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. flex/xunsearch-laravel

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

flex/xunsearch-laravel
======================

基于XunSearch（讯搜）sdk的全文搜索Laravel 5.\*，支持全拼，拼音简写，模糊,同义词搜索

v4.0.1(4y ago)05.7kMITPHPPHP &gt;=5.6

Since Feb 21Pushed 4y agoCompare

[ Source](https://github.com/inbjo/xunsearch-laravel)[ Packagist](https://packagist.org/packages/flex/xunsearch-laravel)[ RSS](/packages/flex-xunsearch-laravel/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (9)Used By (0)

xunsearch-laravel
=================

[](#xunsearch-laravel)

---

[![](https://camo.githubusercontent.com/5294969ddf581a4b2662b45a19be5a27873fd77b358751d7d8f1348a63b199e6/68747470733a2f2f7472617669732d63692e6f72672f5368616f5a654d696e672f78756e7365617263682d6c61726176656c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ShaoZeMing/xunsearch-laravel)[![](https://camo.githubusercontent.com/6d29b14e1f13bb04c82dff82f02506de6c170cdbf208163e788ab31efeae3697/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f5368616f5a654d696e672f78756e7365617263682d6c61726176656c2e737667)](https://packagist.org/packages/shaozeming/xunsearch-laravel)[![](https://camo.githubusercontent.com/dbffd6faecda267136cc5f6ceca9f4e04fd233e56f3f27ddea9ee528fcc52170/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f5368616f5a654d696e672f78756e7365617263682d6c61726176656c2e737667)](https://packagist.org/packages/stichoza/shaozeming/xunsearch-laravel)

- 旧版本请访问 v1.0\[\]

前置说明：
-----

[](#前置说明)

### 请先安装xunsearch 服务端：

[](#请先安装xunsearch-服务端)

- 普通编译安装

```

wget http://www.xunsearch.com/download/xunsearch-full-latest.tar.bz2
tar -xjf xunsearch-full-latest.tar.bz2

cd xunsearch-full-1.4.11/     //下载的版本文件夹
sh setup.sh
//第一次安装的话，过程可能会稍显漫长，请不必着急，您大可泡杯茶一边喝一边等待即可。

cd $prefix ; bin/xs-ctl.sh restart

更多详情请移步：http://www.xunsearch.com/doc/php/guide/start.installation

```

- docker 安装(推荐,可减少环境问题，但你需要安装docker)

```
Docker 方式安装服务端

//下载映像：

docker pull hightman/xunsearch

//启动映像：

docker run --name xunsearch -d \
-p 8383:8383 -p 8384:8384 \
-v /var/xunsearch/data:/usr/local/xunsearch/data \
hightman/xunsearch:latest

//以上启动参数可自行修改，该方式仅运行服务端

```

Installing
----------

[](#installing)

- 非laravel框架请使用

```
$ composer require shaozeming/xunsearch-laravel -v
```

### Laravel

[](#laravel)

```
// config/app.php

    'providers' => [
        //...
        ShaoZeMing\LaravelXunsearch\XunsearchServiceProvider::class,    //This is default in laravel 5.5
    ],
```

And publish the config file:

```
$ php artisan vendor:publish --provider=ShaoZeMing\\LaravelXunsearch\\XunsearchServiceProvider
```

if you want to use facade mode, you can register a facade name what you want to use, for example `xunsearch`:

```
// config/app.php

    'aliases' => [
        'xunsearch' => ShaoZeMing\LaravelXunsearch\Facade\Xunsearch::class,   //This is default in laravel 5.5
    ],
```

### lumen

[](#lumen)

- 在 bootstrap/app.php 中 82 行左右：

```
$app->register( ShaoZeMing\LaravelXunsearch\XunsearchServiceProvider::class);

```

将 `vendor/ShaoZeMing/laravel-xunsearch/config/xunsearch.php` 拷贝到项目根目录`/config`目录下，并将文件名改成`xunsearch.php`。

### configuration

[](#configuration)

- 老师搜索库配置 配置结构和官方ini文件类似，只不过替换为了php 数组形式方式展示，请照着官方文档和本配置文件对比，葫芦画瓢：

```
// config/xunsearch.php

    'default' => 'teacher',   //默认搜索库

    'databases' => [

//        老师搜索库配置 配置结构和官方ini文件类似，只不过替换为了php 数组形式方式展示，请照着官方文档和本配置文件对比，葫芦画瓢：http://www.xunsearch.com/doc/php/guide/ini.guide
        'teacher' => [
            'project.name' => 'teacher',
            'project.default_charset' => 'utf-8',
            'server.index' => '127.0.0.1:8383',
            'server.search' => '127.0.0.1:8384',
            'id' => [
                'type' => 'id',
            ],
            'email' => [
                'index' => 'mixed',
            ],
            'name' => [
                'index' => 'mixed',
            ],
            'desc' => [
                'index' => 'mixed',
            ],

        ],

        //学生搜索库
        'student' => [
            'project.name' => 'student',
            'project.default_charset' => 'utf-8',
            'server.index' => '127.0.0.1:8383',
            'server.search' => '127.0.0.1:8384',
            'id' => [
                'type' => 'id',
            ],
            'email' => [
                'index' => 'mixed',
            ],
            'name' => [
                'index' => 'mixed',
            ],
            'desc' => [
                'index' => 'mixed',
            ],

        ],

//        ... 更多
    ],
```

Example:

```
use ShaoZeMing\LaravelXunsearch\Facade\Xunsearch;

       $data =[
            ['id' => 1, 'email' => '928240096@qq.com', 'name' => 'Shao ZeMing 邵泽明 邵澤明', 'lesson' => '朗诵主持,Reciting Hosting,朗誦主持，','desc'=>'我是谁，我在哪儿，我要做什么，我不告诉你'],
            ['id' => 2, 'email' => '12315@qq.com', 'name' => 'Chris Dong 董胜君  董勝君', 'lesson' => '朗诵主持,Reciting Hosting,朗誦主持，演講辯論，speech debate，演讲辩论','desc'=>'如果有一天，我走了，你应该知道我去了哪儿'],
            ['id' => 3, 'email' => 'shao-ze-ming@outlook.com', 'name' => '二傻子 Two fools', 'lesson' => '朗诵主持,Reciting Hosting,朗誦主持，','desc'=>'最近头发掉的厉害，我该怎么办好呀'],
            ['id' => 4, 'email' => 'szm19920426@qq.com', 'name' => '君莫笑 jun mo xiao 君莫笑', 'lesson' => '写作批改,writing correction,寫作批改,国学经典,National Classics,國學經典','desc'=>'哎呀，脑壳疼，脑壳疼，脑壳疼'],
            ['id' => 5, 'email' => '1270912585@qq.com', 'name' => '李四，li si 李四', 'lesson' => '朗诵主持,Reciting Hosting,朗誦主持，演講辯論，speech debate，演讲辩论，国学经典,National Classics,國學經典','desc'=>'你知道我对你不静静是喜欢'],
        ];

//        Xunsearch::addIndex($data);  //添加索引
//        Xunsearch::setDatabase('student')->addIndex($data);  //添加自定义索引数据库索引

//        $data = ['id'=>1,'email'=>'123456@ming.com'];
//        Xunsearch::updateIndexOne($data); 更新索引
//        Xunsearch::setDatabase('student')->updateIndexOne($data); 更新自定义索引数据库索引

//        Xunsearch::delIndex($ids); 删除索引
//        Xunsearch::setDatabase('student')->delIndex($ids); 删除自定义索引数据库索引

//        Xunsearch::cleanIndex(); 清空索引
//        Xunsearch::setDatabase('student')->cleanIndex(); 清空自定义索引数据库索引

//        $res = Xunsearch::search('朗诵');    //默认搜索
//        $res = Xunsearch::setLimit(15)->search('朗诵');  //搜索每页条数
//        $res = Xunsearch::setSort('id',true)->setLimit(15)->search('朗诵');  //搜索排序
          $res = Xunsearch::setDatabase('student')->setLimit(15)->search('朗诵');  //设置索引数据库

 print_r($res);
  * @return array  返回数组结构
            return [
                      'doc'           => Object,      //搜索数据结果文档
                      'hot'           => array,       //热门词汇
                      'count'         => int,         //搜索结果统计
                      'total'         => int,         //数据库总数据
                      'corrected'     => array,       //搜索提示
                      'related'       => array,       //相关搜索
                      'search_cost'   => float,         //搜索所用时间
                      'total_cost'    => float,         //页面所用时间
                  ];
          */

 /*
 示例结果：
Array
(
    [doc] => Array
        (
            [0] => XSDocument Object
                (
                    [_data:XSDocument:private] => Array
                        (
                            [id] => 1
                            [email] => 928240096@qq.com
                            [name] => Shao ZeMing 邵泽明 邵澤明
                            [lesson] => 朗诵主持,Reciting Hosting,朗誦主持，
                            [desc] => 我是谁，我在哪儿，我要做什么，我不告诉你
                            [255] =>
                        )

                    [_terms:XSDocument:private] =>
                    [_texts:XSDocument:private] =>
                    [_charset:XSDocument:private] => UTF-8
                    [_meta:XSDocument:private] => Array
                        (
                            [docid] => 1
                            [rank] => 1
                            [ccount] => 0
                            [percent] => 100
                            [weight] => 1.1440536975861
                        )

                )

        )

    [hot] => Array
        (
        )

    [count] => 1
    [total] => 5
    [corrected] => Array
        (
        )

    [related] => Array
        (
        )

    [search_cost] => 0.00080204010009766
    [total_cost] => 0.004767894744873
)
 */
```

License
-------

[](#license)

MIT

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 97.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~233 days

Recently: every ~268 days

Total

8

Last Release

1740d ago

Major Versions

v1.0.1 → v2.02018-09-04

v2.0.1 → v3.0.02018-09-11

v3.0.1 → v4.0.02020-03-16

PHP version history (2 changes)v1.0.0PHP &gt;=5.3

v2.0PHP &gt;=5.6

### Community

Maintainers

![](https://www.gravatar.com/avatar/0071a236e8e4c14787e83570e000c43a84b09b404b9fd7c9e383b08eca426afe?d=identicon)[Xiazi](/maintainers/Xiazi)

---

Top Contributors

[![ShaoZeMing](https://avatars.githubusercontent.com/u/19376576?v=4)](https://github.com/ShaoZeMing "ShaoZeMing (45 commits)")[![inbjo](https://avatars.githubusercontent.com/u/11854149?v=4)](https://github.com/inbjo "inbjo (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/flex-xunsearch-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/flex-xunsearch-laravel/health.svg)](https://phpackages.com/packages/flex-xunsearch-laravel)
```

###  Alternatives

[ruflin/elastica

Elasticsearch Client

2.3k50.4M203](/packages/ruflin-elastica)[opensearch-project/opensearch-php

PHP Client for OpenSearch

15224.3M65](/packages/opensearch-project-opensearch-php)[massive/search-bundle

Massive Search Bundle

721.4M13](/packages/massive-search-bundle)[outl1ne/nova-multiselect-filter

Multiselect filter for Laravel Nova.

45802.7k3](/packages/outl1ne-nova-multiselect-filter)[handcraftedinthealps/zendsearch

a general purpose text search engine written entirely in PHP 5

39921.0k35](/packages/handcraftedinthealps-zendsearch)[outl1ne/nova-detached-filters

This Laravel Nova package allows you to detach filters from the filter dropdown

64343.5k](/packages/outl1ne-nova-detached-filters)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
