Search in sources :

Example 6 with DocValuesCollector

use of org.neo4j.kernel.api.impl.index.collector.DocValuesCollector in project neo4j by neo4j.

the class LuceneLegacyIndex method search.

private IndexHits<Document> search(IndexReference searcherRef, IndexSearcher fulltextTransactionStateSearcher, Query query, QueryContext additionalParametersOrNull, Collection<EntityId> removed) throws IOException {
    if (fulltextTransactionStateSearcher != null && !removed.isEmpty()) {
        letThroughAdditions(fulltextTransactionStateSearcher, query, removed);
    }
    IndexSearcher searcher = fulltextTransactionStateSearcher == null ? searcherRef.getSearcher() : new IndexSearcher(new MultiReader(searcherRef.getSearcher().getIndexReader(), fulltextTransactionStateSearcher.getIndexReader()));
    IndexHits<Document> result;
    if (additionalParametersOrNull != null && additionalParametersOrNull.getTop() > 0) {
        result = new TopDocsIterator(query, additionalParametersOrNull, searcher);
    } else {
        Sort sorting = additionalParametersOrNull != null ? additionalParametersOrNull.getSorting() : null;
        boolean forceScore = additionalParametersOrNull == null || !additionalParametersOrNull.getTradeCorrectnessForSpeed();
        DocValuesCollector collector = new DocValuesCollector(forceScore);
        searcher.search(query, collector);
        return collector.getIndexHits(sorting);
    }
    return result;
}
Also used : IndexSearcher(org.apache.lucene.search.IndexSearcher) MultiReader(org.apache.lucene.index.MultiReader) DocValuesCollector(org.neo4j.kernel.api.impl.index.collector.DocValuesCollector) Sort(org.apache.lucene.search.Sort) Document(org.apache.lucene.document.Document)

Example 7 with DocValuesCollector

use of org.neo4j.kernel.api.impl.index.collector.DocValuesCollector in project neo4j by neo4j.

the class LuceneLegacyIndex method letThroughAdditions.

private void letThroughAdditions(IndexSearcher additionsSearcher, Query query, Collection<EntityId> removed) throws IOException {
    // This could be improved further by doing a term-dict lookup for every term in removed
    // and retaining only those that did not match.
    // This is getting quite low-level though
    DocValuesCollector collector = new DocValuesCollector(false);
    additionsSearcher.search(query, collector);
    PrimitiveLongIterator valuesIterator = collector.getValuesIterator(KEY_DOC_ID);
    LongCostume id = new LongCostume();
    while (valuesIterator.hasNext()) {
        long value = valuesIterator.next();
        removed.remove(id.setId(value));
    }
}
Also used : PrimitiveLongIterator(org.neo4j.collection.primitive.PrimitiveLongIterator) LongCostume(org.neo4j.index.impl.lucene.legacy.EntityId.LongCostume) DocValuesCollector(org.neo4j.kernel.api.impl.index.collector.DocValuesCollector)

Example 8 with DocValuesCollector

use of org.neo4j.kernel.api.impl.index.collector.DocValuesCollector in project neo4j by neo4j.

the class SimpleIndexReader method query.

protected PrimitiveLongIterator query(Query query) {
    try {
        DocValuesCollector docValuesCollector = new DocValuesCollector();
        getIndexSearcher().search(query, docValuesCollector);
        return docValuesCollector.getValuesIterator(NODE_ID_KEY);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : DocValuesCollector(org.neo4j.kernel.api.impl.index.collector.DocValuesCollector) IOException(java.io.IOException)

Aggregations

DocValuesCollector (org.neo4j.kernel.api.impl.index.collector.DocValuesCollector)8 IOException (java.io.IOException)4 IndexSearcher (org.apache.lucene.search.IndexSearcher)4 PrimitiveLongIterator (org.neo4j.collection.primitive.PrimitiveLongIterator)4 Sort (org.apache.lucene.search.Sort)3 ArrayList (java.util.ArrayList)2 Document (org.apache.lucene.document.Document)2 LeafReaderContext (org.apache.lucene.index.LeafReaderContext)1 MultiReader (org.apache.lucene.index.MultiReader)1 NumericDocValues (org.apache.lucene.index.NumericDocValues)1 Query (org.apache.lucene.search.Query)1 SortField (org.apache.lucene.search.SortField)1 Test (org.junit.Test)1 PrimitiveLongSet (org.neo4j.collection.primitive.PrimitiveLongSet)1 LongCostume (org.neo4j.index.impl.lucene.legacy.EntityId.LongCostume)1 LegacyIndexHits (org.neo4j.kernel.api.LegacyIndexHits)1 IndexReaderStub (org.neo4j.kernel.api.impl.index.IndexReaderStub)1