Lucene全文檢索之多種查詢方式

2021-10-03 01:39:46 字數 1053 閱讀 3654

步驟

public void searchindex() throws exception 

//9、關閉indexreader物件

indexreader.close();

}

query的子類

rangequery

numericrangequery

prefixquery

fuzzyquery

wildcardquery

例子:wildcardquery query = new wildcardquery(new term("filename","*"));

regexquery

booleanquery

例子

termquery termquery1 = new termquery(new term("filename", "lucene"));

termquery termquery2 = new termquery(new term("filename", "name"));

booleanquery query1 = new booleanquery();

booleanquery query2 = new booleanquery();

query1.add(termquery1, occur.should);

query2.add(termquery2, occur.should);

//組合多個query

query1.add(query2, occur.should);

queryparser

使用querypaser進行查詢,可以對要查詢的內容先分詞,然後基於分詞的結果進行查詢。

public void testqueryparser() throws exception

luke 是用於查詢 lucene / solr / elasticsearch 索引的視覺化工具

lucene 全文檢索

在講全文檢索之前,先說下資訊檢索。資訊檢索通俗的講,就是從資訊集合中找出與使用者相關的資訊,除了文字之外,還有音訊 影象等。全文檢索 把使用者的查詢請求和全文中的每個詞進行比較,不考慮查詢請求與文字語義上的匹配。b 全文檢索是指計算機索引程式通過掃瞄文章中的每乙個詞,對每乙個詞建立乙個索引,指明該詞...

Lucene全文檢索

流程圖 一.建立文件 文件域 注 每乙個doucment可以有多個field,不同的document可以有不同的field,同乙個document可以有相同的field 網域名稱和域值都相同 每乙個文件都有唯一的編號 二.分析文件 將文件中的大寫轉化成小寫,清除 is a 標點 停用詞等過程生成語彙...

Lucene全文檢索初探

1 全文檢索是什麼 先建立索引,再對索引進行搜尋的過程。2 為什麼需要全文檢索 在網頁搜尋時,如果沒有全文檢索,每一次檢索資料都會對資料庫進行查詢,當資料庫的資料量非常大時,搜尋起來非常耗時以及耗費資源,所以我們可以先將資料庫的資料採集出來,提前對這些資料進行整理,建立索引,將這些索引檔案儲存到伺服...