http://lucene.apache.org/java/2_3_1/api/core/org/apache/lucene/search/MultiPhraseQuery.html
对于示例Microsoft app*",他说使用 IndexReader.term()
但返回 TermEnum
,我如何将它放入 MultiPhraseQueryParser代码> ?
for the example "Microsoft app*", he says use IndexReader.term()
but that returns TermEnum
, how do I put it in MultiPhraseQueryParser
?
或者有人告诉我如何在 Microsoft 应用程序* 上以更好的方式搜索超过 7.5 GB 的索引!!
Or someone tell me how do I do a search on Microsoft app* in a better way over a 7.5 GB index!!
您需要迭代 TermEnum 以获取条款.您可以迭代 TermEnum 以获取以app"开头的术语,如下所示.
You need to iterate on TermEnum to get the terms. You can iterate on the TermEnum to get terms starting with "app" as follows.
TermEnum te = reader.terms(new Term("field", "app"));
List<Term> termList = new LinkedList<Term>();
while(te.next()) {
Term t = te.term();
if (!t.field().equals("field") || !t.text().startsWith("app")) {
break;
}
termList.add(t);
}
Term[] terms = termList.toArray(new Term[0]);
这篇关于如何使用多短语查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!