Search in sources :

Example 1 with MultiSearcher

use of org.apache.lucene.search.MultiSearcher in project graphdb by neo4j-attic.

the class LuceneIndex method search.

private IndexHits<Document> search(IndexSearcherRef searcherRef, Query query, QueryContext additionalParametersOrNull, Searcher additionsSearcher, Collection<Long> removed) {
    try {
        if (additionsSearcher != null && !removed.isEmpty()) {
            letThroughAdditions(additionsSearcher, query, removed);
        }
        Searcher searcher = additionsSearcher == null ? searcherRef.getSearcher() : new MultiSearcher(searcherRef.getSearcher(), additionsSearcher);
        IndexHits<Document> result = null;
        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();
            Hits hits = new Hits(searcher, query, null, sorting, forceScore);
            result = new HitsIterator(hits);
        }
        return result;
    } catch (IOException e) {
        throw new RuntimeException("Unable to query " + this + " with " + query, e);
    }
}
Also used : MultiSearcher(org.apache.lucene.search.MultiSearcher) IndexHits(org.neo4j.graphdb.index.IndexHits) MultiSearcher(org.apache.lucene.search.MultiSearcher) Searcher(org.apache.lucene.search.Searcher) Sort(org.apache.lucene.search.Sort) IOException(java.io.IOException) Document(org.apache.lucene.document.Document)

Aggregations

IOException (java.io.IOException)1 Document (org.apache.lucene.document.Document)1 MultiSearcher (org.apache.lucene.search.MultiSearcher)1 Searcher (org.apache.lucene.search.Searcher)1 Sort (org.apache.lucene.search.Sort)1 IndexHits (org.neo4j.graphdb.index.IndexHits)1