use of org.apache.lucene.search.TermRangeFilter in project ignite by apache.
the class GridLuceneIndex method query.
/**
* Runs lucene fulltext query over this index.
*
* @param qry Query.
* @param filters Filters over result.
* @return Query result.
* @throws IgniteCheckedException If failed.
*/
public <K, V> GridCloseableIterator<IgniteBiTuple<K, V>> query(String qry, IndexingQueryFilter filters) throws IgniteCheckedException {
IndexReader reader;
try {
long updates = updateCntr.get();
if (updates != 0) {
writer.commit();
updateCntr.addAndGet(-updates);
}
reader = IndexReader.open(writer, true);
} catch (IOException e) {
throw new IgniteCheckedException(e);
}
IndexSearcher searcher = new IndexSearcher(reader);
MultiFieldQueryParser parser = new MultiFieldQueryParser(Version.LUCENE_30, idxdFields, writer.getAnalyzer());
// Filter expired items.
Filter f = new TermRangeFilter(EXPIRATION_TIME_FIELD_NAME, DateTools.timeToString(U.currentTimeMillis(), DateTools.Resolution.MILLISECOND), null, false, false);
TopDocs docs;
try {
docs = searcher.search(parser.parse(qry), f, Integer.MAX_VALUE);
} catch (Exception e) {
throw new IgniteCheckedException(e);
}
IgniteBiPredicate<K, V> fltr = null;
if (filters != null)
fltr = filters.forCache(cacheName);
return new It<>(reader, searcher, docs.scoreDocs, fltr);
}
Aggregations