how to use a multiphrasequery?

前端 未结 1 901
独厮守ぢ
独厮守ぢ 2021-01-22 09:16

http://lucene.apache.org/java/2_3_1/api/core/org/apache/lucene/search/MultiPhraseQuery.html

for the example \"Microsoft app*\", he says use IndexReader.term()

相关标签:
1条回答
  • 2021-01-22 09:29

    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]);
    
    0 讨论(0)
提交回复
热议问题