1、多欄位搜尋
1)term t1=new term("title","會議");
termquery q1=new termquery(t1);
term t2=new term("context","交通部");
termquery q2=new termquery(t2);
booleanquery q=new booleanquery();
q.add(q1,booleanclause.occur.should);
q.add(q2,booleanclause.occur.should);
2)string fileds=["title","context"];
string keys=["會議","交通部"]
multifieldqueryparser mp=new multifieldqueryparser(fields,new standardanalyzer());
query q=mp.parse(keys);
還例如:
string query = ;
string fields = ;
booleanclause.occur flags = ;
multifieldqueryparser.parse(query, fields, flags, analyzer);
the code above would construct a query:
(filename:query1) +(contents:query2) -(description:query3)
2、多索引
indexsearcher searcher1=new indexsearcher("index1");
indexsearcher searcher2=new indexsearcher("index2");
indexsearcher searchers=;
multisearcher searcher=new multisearcher(searchers);
3、多執行緒
indexsearcher searcher1=new indexsearcher("index1");
indexsearcher searcher2=new indexsearcher("index2");
indexsearcher searchers=;
parallelmultisearcher searcher=new parallelmultisearcher(searchers);
Lucene多字段和多目錄索引
1 多欄位搜尋就是同時要乙個以上的字段中的內容進行比較搜尋,類似概念在sql中就是select from table where a like query or b like query lucene.net中的單個字段查詢大家都比較熟悉,這裡對欄位content進行搜尋 query query q...
lucene多欄位查詢
booleanquery typenegativesearch new booleanquery queryparser parser new queryparser contents new analyzer parser.setdefaultoperator queryparser.and op...
lucene多欄位查詢
我的例子就是2.0的,現在給你的是兩個域,你可以用n個域 booleanquery typenegativesearch new booleanquery queryparser parser new queryparser contents new analyzer parser.setdefau...