elasticsearch - 哪位朋友知道es-php或mmanos/laravel-search的查詢結果高亮問題
以下程式碼是laravel+elastisearch-php(https://github.com/elastic/elasticsearch-php)實現的,但是不能返回高亮內容,網路上看了https://segmentfault.com/a/1190000003010186 下面有一個例子提到高亮,但mmanos的不太會用,例如如何找指定索引下指定類型的某個查詢?
不亂以上哪一種方式,哪位朋友能指點一二,感謝! ! !
<code> $params=[ 'index' => 'n_index', 'type' => 'n_type', 'body' => [ 'query' => [ 'match' => ['ntitle' => '要查询的词'] ], 'highlight'=>[ 'pre_tags'=>['<tag1>', '<tag2>'], 'post_tags'=>['</tag1>', '</tag2>'], 'fields'=>[ 'ntitle'=>[] ] ] ] ]; $response = $this->client->search($params); echo "<pre class="brush:php;toolbar:false">"; var_dump($response); echo "";
以上程式碼可以查出以下結果
<code>array(4) { ["took"]=> int(6) ["timed_out"]=> bool(false) ["_shards"]=> array(3) { ["total"]=> int(5) ["successful"]=> int(5) ["failed"]=> int(0) } ["hits"]=> array(3) { ["total"]=> int(3) ["max_score"]=> float(1.8223838) ["hits"]=> array(3) { [0]=> array(5) { ["_index"]=> string(7) "n_index" ["_type"]=> string(6) "n_type" ["_id"]=> string(1) "6" ["_score"]=> float(1.8223838) ["_source"]=> array(1) { ["ntitle"]=> string(35) "ntitle内容2" } } [1]=> array(5) { ["_index"]=> string(7) "n_index" ["_type"]=> string(6) "n_type" ["_id"]=> string(1) "7" ["_score"]=> float(1.2087858) ["_source"]=> array(1) { ["ntitle"]=> string(35) "ntitle内容1" } } [2]=> array(5) { ["_index"]=> string(7) "n_index" ["_type"]=> string(6) "n_type" ["_id"]=> string(1) "5" ["_score"]=> float(0.23033649) ["_source"]=> array(1) { ["ntitle"]=> string(35) "ntitle内容3" } } } } }</code>
沒有回到高亮部分,
回覆內容:
以下程式碼是laravel+elastisearch-php(https://github.com/elastic/elasticsearch-php)實現的,但是不能返回高亮內容,網路上看了https://segmentfault.com/a/1190000003010186 下面有一個例子提到高亮,但mmanos的不太會用,例如如何找指定索引下指定類型的某個查詢?
不亂以上哪一種方式,哪位朋友能指點一二,感謝! ! !
<code> $params=[ 'index' => 'n_index', 'type' => 'n_type', 'body' => [ 'query' => [ 'match' => ['ntitle' => '要查询的词'] ], 'highlight'=>[ 'pre_tags'=>['<tag1>', '<tag2>'], 'post_tags'=>['</tag1>', '</tag2>'], 'fields'=>[ 'ntitle'=>[] ] ] ] ]; $response = $this->client->search($params); echo "<pre class="brush:php;toolbar:false">"; var_dump($response); echo "";
以上程式碼可以查出以下結果
<code>array(4) { ["took"]=> int(6) ["timed_out"]=> bool(false) ["_shards"]=> array(3) { ["total"]=> int(5) ["successful"]=> int(5) ["failed"]=> int(0) } ["hits"]=> array(3) { ["total"]=> int(3) ["max_score"]=> float(1.8223838) ["hits"]=> array(3) { [0]=> array(5) { ["_index"]=> string(7) "n_index" ["_type"]=> string(6) "n_type" ["_id"]=> string(1) "6" ["_score"]=> float(1.8223838) ["_source"]=> array(1) { ["ntitle"]=> string(35) "ntitle内容2" } } [1]=> array(5) { ["_index"]=> string(7) "n_index" ["_type"]=> string(6) "n_type" ["_id"]=> string(1) "7" ["_score"]=> float(1.2087858) ["_source"]=> array(1) { ["ntitle"]=> string(35) "ntitle内容1" } } [2]=> array(5) { ["_index"]=> string(7) "n_index" ["_type"]=> string(6) "n_type" ["_id"]=> string(1) "5" ["_score"]=> float(0.23033649) ["_source"]=> array(1) { ["ntitle"]=> string(35) "ntitle内容3" } } } } }</code>
沒有回到高亮部分,

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

PHP仍然流行的原因是其易用性、靈活性和強大的生態系統。 1)易用性和簡單語法使其成為初學者的首選。 2)與web開發緊密結合,處理HTTP請求和數據庫交互出色。 3)龐大的生態系統提供了豐富的工具和庫。 4)活躍的社區和開源性質使其適應新需求和技術趨勢。

IIS和PHP可以兼容,通過FastCGI實現。 1.IIS通過配置文件將.php文件請求轉發給FastCGI模塊。 2.FastCGI模塊啟動PHP進程處理請求,提高性能和穩定性。 3.實際應用中需注意配置細節、錯誤調試和性能優化。

Laravel適合團隊熟悉PHP且需功能豐富的項目,Python框架則視項目需求而定。 1.Laravel提供優雅語法和豐富功能,適合需要快速開發和靈活性的項目。 2.Django適合複雜應用,因其“電池包含”理念。 3.Flask適用於快速原型和小型項目,提供極大靈活性。

多次調用session_start()會導致警告信息和可能的數據覆蓋。 1)PHP會發出警告,提示session已啟動。 2)可能導致session數據意外覆蓋。 3)使用session_status()檢查session狀態,避免重複調用。

Laravel優化Web開發流程的方法包括:1.使用路由系統管理URL結構;2.利用Blade模板引擎簡化視圖開發;3.通過隊列處理耗時任務;4.使用EloquentORM簡化數據庫操作;5.遵循最佳實踐提高代碼質量和可維護性。

AI可以幫助優化Composer的使用,具體方法包括:1.依賴管理優化:AI分析依賴關係,建議最佳版本組合,減少衝突。 2.自動化代碼生成:AI生成符合最佳實踐的composer.json文件。 3.代碼質量提升:AI檢測潛在問題,提供優化建議,提高代碼質量。這些方法通過機器學習和自然語言處理技術實現,幫助開發者提高效率和代碼質量。

最新版本的Laravel10與MySQL5.7及以上、PostgreSQL9.6及以上、SQLite3.8.8及以上、SQLServer2017及以上兼容。這些版本選擇是因為它們支持Laravel的ORM功能,如MySQL5.7的JSON數據類型,提升了查詢和存儲效率。

Laravel和Yii的主要區別在於設計理念、功能特性和使用場景。 1.Laravel注重開發的簡潔和愉悅,提供豐富的功能如EloquentORM和Artisan工具,適合快速開發和初學者。 2.Yii強調性能和效率,適用於高負載應用,提供高效的ActiveRecord和緩存系統,但學習曲線較陡。
