use of de.lmu.ifi.dbs.elki.database.ids.integer.DoubleIntegerDBIDKNNList in project elki by elki-project.
the class LuceneDistanceKNNQuery method getKNNForDBID.
@Override
public KNNList getKNNForDBID(DBIDRef id, int k) {
try {
Query query = mlt.like(range.getOffset(id));
TopDocs topDocs = is.search(query, k);
int rk = topDocs.scoreDocs.length;
DoubleIntegerDBIDKNNList res = new DoubleIntegerDBIDKNNList(k, rk);
DBIDArrayIter it = range.iter();
for (ScoreDoc scoreDoc : topDocs.scoreDocs) {
double dist = (scoreDoc.score > 0.) ? (1. / scoreDoc.score) : Double.POSITIVE_INFINITY;
it.seek(scoreDoc.doc);
res.add(dist, it);
}
return res;
} catch (IOException e) {
throw new AbortException("I/O error in lucene.", e);
}
}
Aggregations