国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

基于webman開發(fā)的全文搜索 省去繁瑣配置插件(支持elasticsearch,meilisearch,xunsearch)

TycoonSong

Build Status
Latest Stable Version
Total Downloads
License

安裝

composer require shopwwi/webman-search
  • 如果覺得方便了你 不要吝嗇你的小星星哦 tycoonSong8988354@qq.com

    使用方法

搜索選定器

搜索配置

  • 配置config/plugin/shopwwi/search/app.php 內(nèi)配置 默認不需要配置
  • xunsearch的配置文件config/plugin/shopwwi/search/ini下創(chuàng)建index.ini文件即可
  • 生成密鑰(如果生成了 啟動meilisearch服務(wù)端的時候記得保持一致,其它搜索器不需要)
    php webman shopwwi:search
  • 選定器調(diào)用(默認調(diào)用config設(shè)置的默認)
    use \Shopwwi\WebmanSearch\Facade\Search;
    // id為主鍵字段  index為索引
    $search = Search::use('meilisearch',['id'=>'id','index'=>'index']);
  • 執(zhí)行命令方法

php webman search:create:index // es搜索必須先執(zhí)行此命令創(chuàng)建索引
php webman search:update:index // 更新索引配置
php webman search:drop:index //刪除索引

- 寫入文檔

```php
      $data = [
        ['id' => 1, 'title' => '我從來都不曾承認我其實是個大帥哥' ,'create_at' => 2022-03-24 08:08:08,'type' => 'A'],
        ['id' => 2, 'title' => '時間萬物除我之外' ,'create_at' => 2022-03-24 09:08:08,'type' => 'B'],
        ['id' => 3, 'title' => '你看見我的小熊了嗎?' ,'create_at' => 2022-03-24 10:08:08,'type' => 'B'],
        ['id' => 4, 'title' => '這是一個神奇的世界,因為你永遠不會知道我在哪' ,'create_at' => 2022-03-24 10:08:08,'type' => 'C']
      ]
    $search->create($data); //批量寫入 支持單條 寫入一維數(shù)組即可
  • 更新文檔

      $data = [
        ['id' => 3, 'title' => '你看見我的小熊了嗎?哈哈哈']
      ];
    $search->update($data);  // 批量修改 主鍵必須存在 單條修改寫入一維數(shù)組
  • 刪除文檔

    $search->destroy(3);  //則會刪除id為3的數(shù)據(jù)
    $search->destroy([2,3]); //批量刪除 id為2和3的數(shù)據(jù)
  • 刪除索引
    $search->clear();
  • 數(shù)據(jù)查詢
    use \Shopwwi\WebmanSearch\Facade\Search;
    // 基礎(chǔ)查詢關(guān)鍵詞
    $result = $search->q('我')->get();
    // 全部查詢 默認只顯示20條
    $result = $search->get();
    //指定字段(默認指定所有)
    $result = $search->select(['id','title'])->get();
    //限定查詢數(shù)量 默認為20
    $result = $search->limit(100)->q('我')->get();
    //帶條件搜索(一定要設(shè)定可檢索字段 不然無效,一般在初始化新增之后)
    // where($column, $operator = null, $value = null, string $boolean = 'AND') static 搜索
    // orWhere($column, $operator = null, $value = null) static 搜索或者

    Search::updateFilterableAttributes(['id','title','type','create_at']);
    $result = $search->where('type','B')->limit(100)->q('我')->get();
    $result = $search->where('type','!=','B')->limit(100)->q('我')->get();
    $result = $search->orWhere('type','B')->limit(100)->q('我')->get();
    // whereIn($column, $values, string $boolean = 'AND', bool $not = false) static 存在當中
    // orWhereIn(string $column, $values) static 搜索或者存在當然
    // whereNotIn(string $column,array $values, string $boolean = 'AND') static 搜索不存在當中
    // orWhereNotIn(string $column, $values) static 搜索或者不存在當中
    $result = $search->whereIn('type',['A','B'])->limit(100)->q('我')->get();
    $result = $search->whereNotIn('type',['A','B'])->limit(100)->q('我')->get();
    $result = $search->orWhereIn('type',['A','B'])->limit(100)->q('我')->get();
    $result = $search->orWhereNotIn('type',['A','B'])->limit(100)->q('我')->get();
    // whereRaw($sql,  $boolean = 'AND') static 原生數(shù)據(jù)查詢
    $result = $search->where('type','B')->whereRaw('(id = 1 OR id = 2)')->limit(100)->q('我')->get();
    //whereBetween($column,array $values, string $boolean = 'AND')
    $result = $search->whereBetween('id',[1,5])->limit(100)->q('我')->get();
    //如果您的文檔包含_geo數(shù)據(jù),您可以使用_geoRadius內(nèi)置過濾規(guī)則根據(jù)其地理位置過濾結(jié)果
    $result = $search->where('type','B')->whereRaw('_geoRadius(45.4628328, 9.1076931, 2000)')->limit(100)->q('我')->get();

    // 分頁
    $result = $search->where('type','B')->limit(20)->q('我')->paginate(\request()->input('page',1));

    //關(guān)鍵詞高亮
    $result = $search->where('type','B')->limit(20)->highlight(['title'])->q('我')->paginate(\request()->input('page',1));
  • 獲取建議詞(如搜索s則會出現(xiàn)與s相關(guān)的漢字數(shù)組 ,meilisearch不支持,es請使用原sdk方法查詢)

    
    $result = $search->limit(20)->q('s')->suggest();// 不帶統(tǒng)計數(shù),數(shù)量都為0
    $result = $search->limit(20)->q('s')->suggest(true); // 帶統(tǒng)計數(shù)
  • 獲取指定文檔
    $result = $search->first(2);
  • 字段排序
    // 字段排序(一定要設(shè)定可排序字段 不然無效,一般在初始化新增之后) 
    //1.使用orderBy方法
    $result = $search->where('type','B')->orderBy('create_at','desc')->orderBy('id')->limit(100)->q('我')->get();
    //2.全局設(shè)定
    $result = $search->where('type','B')->limit(100)->q('我')->get();
  • 獲取原SDK方法(各方法請查看各選定器包說明文檔)

    //返回所選定器本身SDK方法
    $search = Search::use('meilisearch',['id'=>'id','index'=>'index'])->us();
    
    //如meilisearch調(diào)用任務(wù)方法
    $search->getTasks(); // 查詢所有任務(wù)
4652 17 39
17個評論

抽不完的寂寞

收藏,后面估計要用到了

  • 暫無評論
Tinywan

贊!

  • 暫無評論
Sdioo

不錯

  • 暫無評論
oscar

正好可以試一下,這個比es小巧一些。
我的規(guī)模也不大。

  • 暫無評論
liziyu

不錯。
收藏,點贊加轉(zhuǎn)發(fā)。

  • 暫無評論
artisan

收藏備用

  • 暫無評論
doit

收藏備用

  • 暫無評論
ersic

很棒??

  • 暫無評論
smart

一個字:牛

  • 暫無評論
晚安。

??

FlyLow

直接運行沒問題 打包Phar后出現(xiàn)找不到類的情況

Class 'Shopwwi\WebmanSearch\Command\SearchCreateIndexCommand' not found in phar:

FlyLow
    'exclude_pattern'   => '#^(?!.*(composer.json|/.github/|/.idea/|/.git/|/.setting/|/runtime/|/vendor-bin/|/build/|/vendor/webman/admin/|/public/cert|public/json/|public/upload/))(.*)$#',

    'exclude_files'     => [
        '.env', 'LICENSE', 'composer.json', 'composer.lock', 'start.php', 'webman.phar', 'webman.bin'
    ]

截圖
看配置文件應(yīng)該是沒有被排除的 現(xiàn)在只有把command里的四個命令都取消了phar包才能正常運行

并且看了phar包里 composer相關(guān)依賴都是有的

這個是phar包下vendor
截圖

  • TycoonSong 2023-06-12

    喔 我的錯 大小寫引起的問題 馬上修復 等會更新版本即可

  • FlyLow 2023-06-12

    ok

  • TycoonSong 2023-06-12

    請更新至v1.0.4試試 如果有問題及時反饋 謝謝

  • FlyLow 2023-06-12

    更新到v1.0.4之后正常了 感謝

FlyLow

截圖

請教下 這個應(yīng)該如何解決呢

  • TycoonSong 2023-06-12

    這個沒看出來是啥問題 是不是數(shù)據(jù)格式不正確?

  • FlyLow 2023-06-12

    數(shù)據(jù)就是普通一維數(shù)組 現(xiàn)在就是普通測試一下 我感覺可能是 es 版本問題 還在定位問題

  • FlyLow 2023-06-13

    切換到7.17.4 es版本就正常了 可能新版本對調(diào)用方式做了一些新的校驗

FlyLow

這個request()會導致在websocket模式下調(diào)用拿不到request對象 要注入一下request對象吧
截圖

  • FlyLow 2023-06-14

    $collect->page = request() ? request()->input('page',1) : 1;

    給加個三元吧 球球了

  • TycoonSong 2023-06-15

    這樣加上也解決不了分頁切換的問題呀

  • FlyLow 2023-06-15

    所以要不改寫下page可傳參,我這里改好之后提個PR?

  • TycoonSong 2023-06-15

    可以的

  • FlyLow 2023-06-16

    PR已申請

  • TycoonSong 2023-06-18

    已合并 并更新

zhangbo

Fatal error: Declaration of Elastic\Elasticsearch\Response\Elasticsearch::withStatus(int $code, string $reasonPhrase = ''): Psr\Http\Message\Resp
onseInterface must be compatible with Psr\Http\Message\ResponseInterface::withStatus($code, $reasonPhrase = '') in D:\php_project\dianwai_api\wz_
im_message\vendor\elasticsearch\elasticsearch\src\Response\Elasticsearch.php on line 87
Worker process terminated with ERROR: E_COMPILE_ERROR "Declaration of Elastic\Elasticsearch\Response\Elasticsearch::withStatus(int $code, string
$reasonPhrase = ''): Psr\Http\Message\ResponseInterface must be compatible with Psr\Http\Message\ResponseInterface::withStatus($code, $reasonPhra
se = '') in D:\php_project\dianwai_api\wz_im_message\vendor\elasticsearch\elasticsearch\src\Response\Elasticsearch.php on line 87"
process D:\php_project\dianwai_api\wz_im_message\start.php terminated and try to restart

wybwsk

小項目想直接用xunsearch,報錯。
PHP 8.1
webman 1.5.6
hightman/xunsearch 1.4.7
xunsearch-server 1.4.17
在config/.../search/下新建ini/goods.ini
業(yè)務(wù)代碼

<?php
declare (strict_types=1);
namespace app\admin\controller\v1;
use Shopwwi\WebmanSearch\Facade\Search;
class SearchController extends BaseController {

    public function test() {
        $search = Search::use('xunsearch', ['id' => 'id', 'index' => 'goods']);

        $data = [
            ['id' => 1, 'title' => '我從來都不曾承認我其實是個大帥哥', 'goods_id' => '123', 'store_id' => 10, 'create_at' => '2022-03-24 08:08:08', 'type' => 'A'],
            ['id' => 2, 'title' => '時間萬物除我之外', 'goods_id' => '132', 'store_id' => 10, 'create_at' => '2022-03-24 09:08:08', 'type' => 'B'],
            ['id' => 3, 'title' => '你看見我的小熊了嗎?', 'goods_id' => '153', 'store_id' => 11, 'create_at' => '2022-03-24 10:08:08', 'type' => 'B'],
            ['id' => 4, 'title' => '這是一個神奇的世界,因為你永遠不會知道我在哪', 'goods_id' => '163', 'store_id' => 12, 'create_at' => '2022-03-24 10:08:08', 'type' => 'C']
        ];
        $search->create($data);
        $res = $search->q('我')->get();
        d($res);
    }
}

PHP Fatal error: During inheritance of ArrayAccess: Uncaught [XSErrorException] vendor/hightman/xunsearch/lib/XSDocument.class.php(300): Return type of XSDocument::offsetGet($name) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice(8192) in /www/wwwroot/admin.webman.com/vendor/hightman/xunsearch/lib/XSDocument.class.php on line 43

Fatal error: During inheritance of ArrayAccess: Uncaught [XSErrorException] vendor/hightman/xunsearch/lib/XSDocument.class.php(300): Return type of XSDocument::offsetGet($name) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice(8192) in /www/wwwroot/admin.webman.com/vendor/hightman/xunsearch/lib/XSDocument.class.php on line 43
Worker[1235] process terminated with ERROR: E_ERROR "During inheritance of ArrayAccess: Uncaught [XSErrorException] vendor/hightman/xunsearch/lib/XSDocument.class.php(300): Return type of XSDocument::offsetGet($name) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice(8192) in /www/wwwroot/admin.webman.com/vendor/hightman/xunsearch/lib/XSDocument.class.php on line 43"
worker[webman:1235] exit with status 65280

  • 暫無評論
晚安。

截圖這是啥問題

  • 晚安。 2023-10-26

    這個elasticsearch 有賬號密碼 在配置文件需要怎么傳入

年代過于久遠,無法發(fā)表評論

TycoonSong

1204
積分
0
獲贊數(shù)
0
粉絲數(shù)
2021-10-29 加入
??