上**
import org.apache.lucene.document.document;
import org.apache.lucene.document.field;
import org.apache.lucene.index.indexwriter;
import org.apache.lucene.queryparser.multifieldqueryparser;
import org.apache.lucene.search.booleanclause;
import org.apache.lucene.search.hits;
import org.apache.lucene.search.indexsearcher;
import org.apache.lucene.search.multisearcher;
import org.apache.lucene.search.query;
public class multisearcher
public static void multisearcher() throws exception ;
//指定兩個域field
string field1 = "bookname";
string field2 = "price";
string fields = ;
//指定查詢字句之間的關係
booleanclause.occur clauses = ;
//轉成多域查詢multifieldquery
query q = multifieldqueryparser.parse(queries, fields, clauses, new standardanalyzer());
//列印query的內容
system.out.println(q.tostring());
//建立兩個indexsearcher,以實現在多個索引目錄進行查詢
indexsearcher searcher1 = new indexsearcher(index_store_path1);
indexsearcher searcher2 = new indexsearcher(index_store_path2);
indexsearcher searchers = ;
//使用multisearcher進行多域搜尋
multisearcher searcher = new multisearcher(searchers);
hits hits = searcher.search(q);
for (int i = 0; i < hits.length(); i++)
}}
Lucene在多個索引上進行搜尋
資訊源自 http blog.csdn.net caoxu1987728 archive 2008 04 27 2335730.aspx 如下 package com.lucene.search import org.apache.lucene.analysis.standard.standarda...
lucene 多索引目錄搜尋實現方法
多索引目錄就是要在多個索引目錄的中進行比較搜尋,類似概念在sql中就是select from tablea union select from tableb。indexsearcher searchers new indexsearcher 2 searchers 0 new indexsearch...
lucene 多索引目錄搜尋實現方法
多索引目錄就是要在多個索引目錄的中進行比較搜尋,類似概念在sql中就是select from tablea union select from tableb。indexsearcher searchers new indexsearcher 2 searchers 0 new indexsearch...