通過solrj獲取solr檢索結果
1、通過solrparams的方式提交查詢引數
2、通過solrquery提交引數
//設定高亮
query.setquery("name:datou");
query.sethighlight(
true); //
開啟高亮元件或用query.setparam("hl", "true");
query.addhighlightfield("name");//
高亮字段
query.sethighlight******pre("");//
標記,高亮關鍵字字首
query.sethighlight******post("");//
字尾
//結果分片數,預設為1
//每個分片的最大長度,預設為100
system.out.println(query);
//用於除錯程式
queryresponse rsp =solr.query(query);
namedlist list = (namedlist) rsp.getresponse().get("highlighting");
system.out.println(list);
//用於顯示list中的值
for (int i = 0; i < list.size(); i++)
Solr5 3 1 SolrJ查詢索引結果
通過solrj獲取solr檢索結果 1 通過solrparams的方式提交查詢引數 2 通過solrquery提交引數 設定高亮 query.setquery name datou query.sethighlight true 開啟高亮元件或用query.setparam hl true quer...
solrj操作solr索引庫 流程
宣告 博主自己記錄以免忘記,所以無邏輯無參考價值。小女子就是醬紫任性 首先dao層 訪問索引庫的類。定義一些通用的資料訪問方法。業務邏輯就是查詢索引庫。引數 solrquery物件 業務邏輯 1 根據query物件進行查詢。2 返回查詢結果。list 查詢結果的總記錄數。需要把返回結果封裝到pojo...
使用solrj索引查詢
1 查詢 solrj提供的查詢功能比較強大,可以進行結果中查詢 範圍查詢 排序等。下面是筆者封裝的乙個查詢函式 public static queryresponse search string field,string key,int start,int count,string sortfiel...