SpringBoot實現ES簡單搜尋和推薦

2021-10-21 03:58:45 字數 652 閱讀 1854

// es高階客戶端

public resthighlevelclient resthighlevelclient()

public list> query()

// add the list

data.add(sourcemap);

}} catch (ioexception e)

return data;

}// title的型別是"type": "completion",index不能是true(索引功能關閉)

// 完整推薦, 例如:keyword=中國,則會推薦「中國經濟不斷發展,中國進入世貿組織」(title的整個欄位的內容)

public setcompletionsuggestdata(string keyword)}}

}} catch (ioexception e)

return data;

}// 推薦相似的詞和短語

// 例如:keyword=中國人民,則會推薦「中國企業, 中國經濟, 中國移動, 中國國際」(資料庫裡必須有相關的字段資料)

public settermsuggestdata(string keyword)}}

}} catch (ioexception e)

return data;

}

springboot整合es詳解

1.匯入 m en依賴 org.springframework.boot spring boot starter dataelasticsearch 注意 保持版本一致 我用的是7.6.2版本的 1.87.6.2 2.編寫config類 相當於 xlm匯入文件 configuration publi...

Spring Boot原始碼簡析 二

load 資源過程load context,sources.toarray new object sources.size load主要就是把我們傳入的資源生成相應的beandefinition。protected void 建立乙個beandefinitionloader,看名字就知道使用來載入b...

極簡SpringBoot配置beetl模板引擎

這是乙個國產的,超過thymeleaf效能十倍的模板引擎,沒有理由不學會它 我們建立乙個springboot專案 在專案中pom檔案中加入 org.springframework.boot spring boot starter web com.ibeetl beetl framework star...