【发布时间】:2013-02-20 11:22:43
【问题描述】:
Here are some code to access terms in a Lucene document:
int docId = hits[i].doc;
TermFreqVector tfvector = reader.getTermFreqVector(docId, "contents");
TermPositionVector tpvector = (TermPositionVector)tfvector;
// this part works only if there is one term in the query string,
// otherwise you will have to iterate this section over the query terms.
int termidx = tfvector.indexOf(querystr);
int[] termposx = tpvector.getTermPositions(termidx);
TermVectorOffsetInfo[] tvoffsetinfo = tpvector.getOffsets(termidx);
我的问题是,使用 termposx,如何根据 termposx 数组获取术语?
【问题讨论】:
-
在给定的情况下,'querystr' 是术语,因为它用于检索 termposx。
-
谢谢,例如 termposx 有 {7, 19, 34}。 8 或 9 的术语是什么?如何访问它?