<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                [https://www.jb51.net/article/179295.htm](https://www.jb51.net/article/179295.htm) 這篇文章主要介紹了Laravel + Elasticsearch 實現中文搜索的方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧 [![](https://files.jb51.net/file_images/article/202002/202002020903021.jpg)](https://files.jb51.net/file_images/article/202002/202002020903021.jpg) **Elasticsearch** Elasticsearch 是一個基于 Apache Lucene(TM) 的開源搜索引擎,無論在開源還是專有領域,Lucene可 以被認為是迄今為止最先進、性能最好的、功能最全的搜索引擎庫。 但是,Lucene 只是一個庫。想要發揮其強大的作用,你需使用 Java 并要將其集成到你的應用中。Lucene 非常復雜,你需要深入的了解檢索相關知識來理解它是如何工作的。 Elasticsearch 也是使用 Java 編寫并使用 Lucene 來建立索引并實現搜索功能,但是它的目的是通過簡單連貫的 RESTful API 讓全文搜索變得簡單并隱藏 Lucene 的復雜性。 不過,Elasticsearch 不僅僅是 Lucene 和全文搜索引擎,它還提供: * 分布式的實時文件存儲,每個字段都被索引并可被搜索 * 實時分析的分布式搜索引擎 * 可以擴展到上百臺服務器,處理PB級結構化或非結構化數據 而且,所有的這些功能被集成到一臺服務器,你的應用可以通過簡單的 RESTful API、各種語言的客戶端甚至命令行與之交互。上手 Elasticsearch 非常簡單,它提供了許多合理的缺省值,并對初學者隱藏了復雜的搜索引擎理論。它開箱即用(安裝即可使用),只需很少的學習既可在生產環境中使用。 Elasticsearch 在 Apache 2 license 下許可使用,可以免費下載、使用和修改。 **ElasticSearch 安裝** 在 Laradock 中已經集成了 ElasticSearch。我們可以直接使用: 1docker-compose up -d elasticsearch 如果需要安裝插件,執行命令: 1234docker-compose exec elasticsearch /usr/share/elasticsearch/bin/elasticsearch-plugin install {plugin-name}&nbsp;// 重啟容器docker-compose restart elasticsearch *注:* > The vm.max\_map\_count kernel setting must be set to at least 262144 for production use. > > 由于我是 centos 7 環境,直接設置在系統設置: > `sysctl -w vm.max_map_count=262144` > > 默認用戶名和密碼:「elastic」、「changeme」,端口號:9200 [![](https://files.jb51.net/file_images/article/202002/202002020903032.jpg)](https://files.jb51.net/file_images/article/202002/202002020903032.jpg) **ElasticHQ** ![](https://files.jb51.net/file_images/article/202002/202002020903033.jpg) > ElasticHQ is an open source application that offers a simplified interface for managing and monitoring Elasticsearch clusters. > > Management and Monitoring for Elasticsearch. > > http://www.elastichq.org/ * Real-Time Monitoring * Full Cluster Management * Full Cluster Monitoring * Elasticsearch Version Agnostic * Easy Install - Always On * Works with X-Pack [![](https://files.jb51.net/file_images/article/202002/202002020903034.jpg)](https://files.jb51.net/file_images/article/202002/202002020903034.jpg) 輸入我們的 Elasticsearch Host,即可進入后臺。 [![](https://files.jb51.net/file_images/article/202002/202002020903035.jpg)](https://files.jb51.net/file_images/article/202002/202002020903035.jpg) 默認的創建了: > 一個集群 cluster:laradock-cluster > 一個節點 node:laradock-node > 一個索引 index:.elastichq **IK 分詞器安裝** ElasticSearch 主要是用于自己 blog 或者公眾號文章的搜索使用,所以需要選擇一個中文分詞器配合使用,這里剛開始推薦使用 IK 分詞器,下面開始安裝對應 ElasticSearch版本 (7.5.1) 一致的插件: [https://github.com/medcl/elasticsearch-analysis-ik/releases](https://github.com/medcl/elasticsearch-analysis-ik/releases) [![](https://files.jb51.net/file_images/article/202002/202002020903046.jpg)](https://files.jb51.net/file_images/article/202002/202002020903046.jpg) 12// 安裝插件docker-compose exec elasticsearch /usr/share/elasticsearch/bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.5.1/elasticsearch-analysis-ik-7.5.1.zip [![](https://files.jb51.net/file_images/article/202002/202002020903047.jpg)](https://files.jb51.net/file_images/article/202002/202002020903047.jpg) > 注:可以將 zip 文件先下載回來,然后再安裝,速度會快些。 **檢驗分詞效果** 根據 Elasticsearch API 測試,分詞的效果達到了: 12345678910111213141516171819202122232425262728293031323334353637383940414243444546~ curl -X POST "http://your_host/_analyze?pretty" -H 'Content-Type: application/json' -d'{&nbsp;"analyzer": "ik_max_word",&nbsp;"text":&nbsp;&nbsp; "我是中國人"}'&nbsp;{&nbsp;"tokens" : [&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;"token" : "我",&nbsp;&nbsp;&nbsp;"start_offset" : 0,&nbsp;&nbsp;&nbsp;"end_offset" : 1,&nbsp;&nbsp;&nbsp;"type" : "CN_CHAR",&nbsp;&nbsp;&nbsp;"position" : 0&nbsp;&nbsp;},&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;"token" : "是",&nbsp;&nbsp;&nbsp;"start_offset" : 1,&nbsp;&nbsp;&nbsp;"end_offset" : 2,&nbsp;&nbsp;&nbsp;"type" : "CN_CHAR",&nbsp;&nbsp;&nbsp;"position" : 1&nbsp;&nbsp;},&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;"token" : "中國人",&nbsp;&nbsp;&nbsp;"start_offset" : 2,&nbsp;&nbsp;&nbsp;"end_offset" : 5,&nbsp;&nbsp;&nbsp;"type" : "CN_WORD",&nbsp;&nbsp;&nbsp;"position" : 2&nbsp;&nbsp;},&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;"token" : "中國",&nbsp;&nbsp;&nbsp;"start_offset" : 2,&nbsp;&nbsp;&nbsp;"end_offset" : 4,&nbsp;&nbsp;&nbsp;"type" : "CN_WORD",&nbsp;&nbsp;&nbsp;"position" : 3&nbsp;&nbsp;},&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;"token" : "國人",&nbsp;&nbsp;&nbsp;"start_offset" : 3,&nbsp;&nbsp;&nbsp;"end_offset" : 5,&nbsp;&nbsp;&nbsp;"type" : "CN_WORD",&nbsp;&nbsp;&nbsp;"position" : 4&nbsp;&nbsp;}&nbsp;]} **結合 Laravel** 雖然 Elasticsearch 官方提供了對應的 PHP 版本的插件,但我們還是希望和 Laravel 結合的更緊密些,所以這里選擇和 Scout 結合使用,具體用到了`tamayo/laravel-scout-elastic`插件。 12345composer require tamayo/laravel-scout-elastic&nbsp;&nbsp;composer require laravel/scout&nbsp;&nbsp;php artisan vendor:publish 選擇:`Laravel\Scout\ScoutServiceProvider` [![](https://files.jb51.net/file_images/article/202002/202002020903048.jpg)](https://files.jb51.net/file_images/article/202002/202002020903048.jpg) 修改驅動為`elasticsearch`: 1'driver' =&gt; env('SCOUT_DRIVER', 'elasticsearch'), **創建索引** 創建索引有幾種方法,其中可以使用 Ela 可視化工具 ElasticHQ 直接創建。 [![](https://files.jb51.net/file_images/article/202002/202002020903059.jpg)](https://files.jb51.net/file_images/article/202002/202002020903059.jpg) [![](https://files.jb51.net/file_images/article/202002/2020020209030510.jpg)](https://files.jb51.net/file_images/article/202002/2020020209030510.jpg) 接下來我們需要更新這個索引,補充 Mappings 這部分,可以用 Postman。 ![](https://files.jb51.net/file_images/article/202002/2020020209030511.jpg) 另一種方法是用 Laravel 自帶的 Artisan 命令行功能。 > 這里我們推薦使用 Artisan 命令行。 1php artisan make:command ESOpenCommand 根據官網提示,我們可以在`ESOpenCommand`上向 Elasticsearch 服務器發送 PUT 請求,這里借助 Elasticsearch 提供的 PHP 插件,在我們使用`tamayo/laravel-scout-elastic`插件時,已經安裝了 Elasticsearch PHP 插件: [![](https://files.jb51.net/file_images/article/202002/2020020209030612.jpg)](https://files.jb51.net/file_images/article/202002/2020020209030612.jpg) 下面就可以借助插件,創建我們的 Index,直接看代碼: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748public function handle()&nbsp;&nbsp;{&nbsp;&nbsp;$host = config('scout.elasticsearch.hosts');&nbsp;&nbsp;$index = config('scout.elasticsearch.index');&nbsp;&nbsp;$client = ClientBuilder::create()-&gt;setHosts($host)-&gt;build();&nbsp;&nbsp;&nbsp;if ($client-&gt;indices()-&gt;exists(['index' =&gt; $index])) {&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;warn("Index {$index} exists, deleting...");&nbsp;&nbsp;&nbsp;&nbsp;$client-&gt;indices()-&gt;delete(['index' =&gt; $index]);&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;$this-&gt;info("Creating index: {$index}");&nbsp;&nbsp;&nbsp;return $client-&gt;indices()-&gt;create([&nbsp;&nbsp;&nbsp;&nbsp;'index' =&gt; $index,&nbsp;&nbsp;&nbsp;&nbsp;'body' =&gt; [&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'settings' =&gt; [&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'number_of_shards' =&gt; 1,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'number_of_replicas' =&gt; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;],&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'mappings' =&gt; [&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'_source' =&gt; [&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'enabled' =&gt; true&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;],&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'properties' =&gt; [&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'id' =&gt; [&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type' =&gt; 'long'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;],&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'title' =&gt; [&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type' =&gt; 'text',&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'analyzer' =&gt; 'ik_max_word',&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'search_analyzer' =&gt; 'ik_smart'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;],&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'subtitle' =&gt; [&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type' =&gt; 'text',&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'analyzer' =&gt; 'ik_max_word',&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'search_analyzer' =&gt; 'ik_smart'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;],&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'content' =&gt; [&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type' =&gt; 'text',&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'analyzer' =&gt; 'ik_max_word',&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'search_analyzer' =&gt; 'ik_smart'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;],&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]&nbsp;&nbsp;&nbsp;&nbsp;]&nbsp;&nbsp;]);} [![](https://files.jb51.net/file_images/article/202002/2020020209030613.jpg)](https://files.jb51.net/file_images/article/202002/2020020209030613.jpg) 好了,我們執行 Kibana 看到我們已經創建好了 Index: [![](https://files.jb51.net/file_images/article/202002/2020020209030614.jpg)](https://files.jb51.net/file_images/article/202002/2020020209030614.jpg) > 注 Kibana 本地 Docker 安裝: > > 后續會重點說明 Kibana 如何使用 1docker run -d --name kibana -e ELASTICSEARCH_HOSTS=http://elasticsearch_host -p 5601:5601 -e SERVER_NAME=ki.test kibana:7.5.2 為了驗證 Index 是否可用,可以插入一條數據看看: 12curl -XPOST your_host/coding01_open/_create/1 -H 'Content-Type:application/json' -d'{"content":"中韓漁警沖突調查:韓警平均每天扣1艘中國漁船"} [![](https://files.jb51.net/file_images/article/202002/2020020209030615.jpg)](https://files.jb51.net/file_images/article/202002/2020020209030615.jpg) 可以通過瀏覽器看看對應的數據: [![](https://files.jb51.net/file_images/article/202002/2020020209030716.jpg)](https://files.jb51.net/file_images/article/202002/2020020209030716.jpg) 有了 Index,下一步我們就可以結合 Laravel,導入、更新、查詢等操作了。 **Laravel Model 使用** Laravel 框架已經為我們推薦使用 Scout 全文搜索,我們只需要在 Article Model 加上官方所說的內容即可,很簡單,推薦大家看 Scout 使用文檔:[https://learnku.com/docs/laravel/6.x/scout/5191](https://learnku.com/docs/laravel/6.x/scout/5191),下面直接上代碼: 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586&lt;?php&nbsp;namespace App;&nbsp;use App\Tools\Markdowner;use Illuminate\Database\Eloquent\Model;use Illuminate\Database\Eloquent\SoftDeletes;use Laravel\Scout\Searchable;&nbsp;class Article extends Model{&nbsp;&nbsp;use Searchable;&nbsp;&nbsp;&nbsp;protected $connection = 'blog';&nbsp;&nbsp;protected $table = 'articles';&nbsp;&nbsp;use SoftDeletes;&nbsp;&nbsp;&nbsp;/**&nbsp;&nbsp;&nbsp;* The attributes that should be mutated to dates.&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;* @var array&nbsp;&nbsp;&nbsp;*/&nbsp;&nbsp;protected $dates = ['published_at', 'created_at', 'deleted_at'];&nbsp;&nbsp;&nbsp;/**&nbsp;&nbsp;&nbsp;* The attributes that are mass assignable.&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;* @var array&nbsp;&nbsp;&nbsp;*/&nbsp;&nbsp;protected $fillable = [&nbsp;&nbsp;&nbsp;&nbsp;'user_id',&nbsp;&nbsp;&nbsp;&nbsp;'last_user_id',&nbsp;&nbsp;&nbsp;&nbsp;'category_id',&nbsp;&nbsp;&nbsp;&nbsp;'title',&nbsp;&nbsp;&nbsp;&nbsp;'subtitle',&nbsp;&nbsp;&nbsp;&nbsp;'slug',&nbsp;&nbsp;&nbsp;&nbsp;'page_image',&nbsp;&nbsp;&nbsp;&nbsp;'content',&nbsp;&nbsp;&nbsp;&nbsp;'meta_description',&nbsp;&nbsp;&nbsp;&nbsp;'is_draft',&nbsp;&nbsp;&nbsp;&nbsp;'is_original',&nbsp;&nbsp;&nbsp;&nbsp;'published_at',&nbsp;&nbsp;&nbsp;&nbsp;'wechat_url',&nbsp;&nbsp;];&nbsp;&nbsp;&nbsp;protected $casts = [&nbsp;&nbsp;&nbsp;&nbsp;'content' =&gt; 'array'&nbsp;&nbsp;];&nbsp;&nbsp;&nbsp;/**&nbsp;&nbsp;&nbsp;* Set the content attribute.&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;* @param $value&nbsp;&nbsp;&nbsp;*/&nbsp;&nbsp;public function setContentAttribute($value)&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;$data = [&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'raw' =&gt; $value,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'html' =&gt; (new Markdowner)-&gt;convertMarkdownToHtml($value)&nbsp;&nbsp;&nbsp;&nbsp;];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;attributes['content'] = json_encode($data);&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;/**&nbsp;&nbsp;&nbsp;* 獲取模型的可搜索數據&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;* @return array&nbsp;&nbsp;&nbsp;*/&nbsp;&nbsp;public function toSearchableArray()&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;$data = [&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'id' =&gt; $this-&gt;id,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'title' =&gt; $this-&gt;title,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'subtitle' =&gt; $this-&gt;subtitle,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'content' =&gt; $this-&gt;content['html']&nbsp;&nbsp;&nbsp;&nbsp;];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return $data;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;public function searchableAs()&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;return '_doc';&nbsp;&nbsp;}} Scout 提供了 Artisan 命令 import 用來導入所有已存在的記錄到搜索索引中。 1php artisan scout:import "App\Article" [![](https://files.jb51.net/file_images/article/202002/2020020209030717.jpg)](https://files.jb51.net/file_images/article/202002/2020020209030717.jpg) 看看 Kibana,已存入 12 條數據,和數據庫條數吻合。 [![](https://files.jb51.net/file_images/article/202002/2020020209030718.jpg)](https://files.jb51.net/file_images/article/202002/2020020209030718.jpg) 有了數據,我們可以測試看看能不能查詢到數據。 還是一樣的,創建一個命令: 12345678910111213141516171819202122232425262728293031323334353637class ElasearchCommand extends Command{&nbsp;&nbsp;/**&nbsp;&nbsp;&nbsp;* The name and signature of the console command.&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;* @var string&nbsp;&nbsp;&nbsp;*/&nbsp;&nbsp;protected $signature = 'command:search {query}';&nbsp;&nbsp;&nbsp;/**&nbsp;&nbsp;&nbsp;* The console command description.&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;* @var string&nbsp;&nbsp;&nbsp;*/&nbsp;&nbsp;protected $description = 'Command description';&nbsp;&nbsp;&nbsp;/**&nbsp;&nbsp;&nbsp;* Create a new command instance.&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;* @return void&nbsp;&nbsp;&nbsp;*/&nbsp;&nbsp;public function __construct()&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;parent::__construct();&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;/**&nbsp;&nbsp;&nbsp;* Execute the console command.&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;* @return mixed&nbsp;&nbsp;&nbsp;*/&nbsp;&nbsp;public function handle()&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;$article = Article::search($this-&gt;argument('query'))-&gt;first();&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;info($article-&gt;title);&nbsp;&nbsp;}} ![](https://files.jb51.net/file_images/article/202002/2020020209030819.jpg) 這是我的 titles,我隨便輸入一個關鍵字:「清單」,看是否能搜到。 [![](https://files.jb51.net/file_images/article/202002/2020020209030820.jpg)](https://files.jb51.net/file_images/article/202002/2020020209030820.jpg) **總結** 整體完成了: * Elasticsearch 安裝; * Elasticsearch IK 分詞器插件安裝; * Elasticsearch 可視化工具 ElasticHQ 和 Kibana 的安裝和簡單使用; * Scout 的使用; * Elasticsearch 和 Scout 結合使用。 接下來就要將更多的內容存入 Elasticsearch 中,為自己的 blog、公眾號、自動化搜索等場景提供全文搜索。 **參考** 推薦一個命令行應用開發工具——[Laravel Zero](https://mp.weixin.qq.com/s/RKEuz5gd8mOoCWfT2A3xzQ) Artisan 命令行[https://learnku.com/docs/laravel/6.x/artisan/5158](https://learnku.com/docs/laravel/6.x/artisan/5158) Scout 全文搜索[https://learnku.com/docs/laravel/6.x/scout/5191](https://learnku.com/docs/laravel/6.x/scout/5191) How to integrate Elasticsearch in your Laravel App – 2019 edition[https://madewithlove.be/how-to-integrate-elasticsearch-in-your-laravel-app-2019-edition/](https://madewithlove.be/how-to-integrate-elasticsearch-in-your-laravel-app-2019-edition/) Kibana Guide[https://www.elastic.co/guide/en/kibana/index.html](https://www.elastic.co/guide/en/kibana/index.html) elasticsearch php-api \[[https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/index.html\](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/index.html](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/index.html](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/index.html)) 以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看