/** * Search implementation with arbitrary sorting. * @param query The query to search for * @param n Return only the top n results * @param sort The {@link org.apache.lucene.search.Sort} object * @return The top docs, sorted according to the supplied {@link org.apache.lucene.search.Sort} instance * @throws IOException if there is a low-level I/O error */ public TopFieldDocs search(Query query, int n, Sort sort) throws IOException { return searchAfter(null, query, n, sort, false, false); }
/** Finds the top <code>n</code> * hits for <code>query</code>. * * @throws BooleanQuery.TooManyClauses If a query would exceed * {@link BooleanQuery#getMaxClauseCount()} clauses. */ public TopDocs search(Query query, int n) throws IOException { return searchAfter(null, query, n); }
/** Finds the top <code>n</code> * hits for <code>query</code> where all results are after a previous * result (<code>after</code>). * <p> * By passing the bottom result from a previous page as <code>after</code>, * this method can be used for efficient 'deep-paging' across potentially * large result sets. * * @throws BooleanQuery.TooManyClauses If a query would exceed * {@link BooleanQuery#getMaxClauseCount()} clauses. */ public TopDocs searchAfter(ScoreDoc after, Query query, int n, Sort sort) throws IOException { return searchAfter(after, query, n, sort, false, false); }
/** Search implementation with arbitrary sorting, plus * control over whether hit scores and max score * should be computed. Finds * the top <code>n</code> hits for <code>query</code>, and sorting * the hits by the criteria in <code>sort</code>. * If <code>doDocScores</code> is <code>true</code> * then the score of each hit will be computed and * returned. If <code>doMaxScore</code> is * <code>true</code> then the maximum score over all * collected hits will be computed. * * @throws BooleanQuery.TooManyClauses If a query would exceed * {@link BooleanQuery#getMaxClauseCount()} clauses. */ public TopFieldDocs search(Query query, int n, Sort sort, boolean doDocScores, boolean doMaxScore) throws IOException { return searchAfter(null, query, n, sort, doDocScores, doMaxScore); }
/** Finds the top <code>n</code> * hits for <code>query</code> where all results are after a previous * result (<code>after</code>), allowing control over * whether hit scores and max score should be computed. * <p> * By passing the bottom result from a previous page as <code>after</code>, * this method can be used for efficient 'deep-paging' across potentially * large result sets. If <code>doDocScores</code> is <code>true</code> * then the score of each hit will be computed and * returned. If <code>doMaxScore</code> is * <code>true</code> then the maximum score over all * collected hits will be computed. * * @throws BooleanQuery.TooManyClauses If a query would exceed * {@link BooleanQuery#getMaxClauseCount()} clauses. */ public TopFieldDocs searchAfter(ScoreDoc after, Query query, int numHits, Sort sort, boolean doDocScores, boolean doMaxScore) throws IOException { if (after != null && !(after instanceof FieldDoc)) { // TODO: if we fix type safety of TopFieldDocs we can // remove this throw new IllegalArgumentException("after must be a FieldDoc; got " + after); } return searchAfter((FieldDoc) after, query, numHits, sort, doDocScores, doMaxScore); }
private TopDocs searchOperations(ScoreDoc after) throws IOException { final Query rangeQuery = LongPoint.newRangeQuery(SeqNoFieldMapper.NAME, Math.max(fromSeqNo, lastSeenSeqNo), toSeqNo); final Sort sortedBySeqNoThenByTerm = new Sort( new SortField(SeqNoFieldMapper.NAME, SortField.Type.LONG), new SortField(SeqNoFieldMapper.PRIMARY_TERM_NAME, SortField.Type.LONG, true) ); return indexSearcher.searchAfter(after, rangeQuery, searchBatchSize, sortedBySeqNoThenByTerm); }
/** * Search implementation with arbitrary sorting. * @param query The query to search for * @param n Return only the top n results * @param sort The {@link org.apache.lucene.search.Sort} object * @return The top docs, sorted according to the supplied {@link org.apache.lucene.search.Sort} instance * @throws IOException if there is a low-level I/O error */ public TopFieldDocs search(Query query, int n, Sort sort) throws IOException { return searchAfter(null, query, n, sort, false, false); }
/** Finds the top <code>n</code> * hits for <code>query</code>. * * @throws BooleanQuery.TooManyClauses If a query would exceed * {@link BooleanQuery#getMaxClauseCount()} clauses. */ public TopDocs search(Query query, int n) throws IOException { return searchAfter(null, query, n); }
/** Finds the top <code>n</code> * hits for <code>query</code>. * * @throws BooleanQuery.TooManyClauses If a query would exceed * {@link BooleanQuery#getMaxClauseCount()} clauses. */ public TopDocs search(Query query, int n) throws IOException { return searchAfter(null, query, n); }
public TopDocs searchAfter(final ScoreDoc after, Query query, int numHits, Sort order) { try { return searcher.searchAfter(after, query, numHits, order); } catch(IllegalArgumentException ex) { // we got to end of index. return null; } catch(IOException ex){ throw Throwables.propagate(ex); } }
private LazySolrDocumentSet(IndexSearcher searcher, Query query, Sort sort) { this.searcher = searcher; this.query = query; this.sort = sort; try { TopDocs topDocs = searcher.searchAfter(null, query, pageLimit, sort); page = topDocs.scoreDocs; pageHitsRead = 0; } catch (IOException e) { LOGGER.error("Could not retrieve documents", e); } }
@Override public TopDocs searchAfter(ScoreDoc after, Query query, int n, Sort sort) throws IOException { try (Ticker ignored = searchAfterMetric.start()) { return super.searchAfter(after, query, n, sort); } }
@Override public TopDocs searchAfter(ScoreDoc after, Query query, int n) throws IOException { try (Ticker ignored = searchAfterMetric.start()) { return super.searchAfter(after, query, n); } }
@Override public TopDocs searchAfter(ScoreDoc after, Query query, Filter filter, int n, Sort sort) throws IOException { try (Ticker ignored = searchAfterMetric.start()) { return super.searchAfter(after, query, filter, n, sort); } }
@Override public TopDocs searchAfter(ScoreDoc after, Query query, Filter filter, int n, Sort sort, boolean doDocScores, boolean doMaxScore) throws IOException { try (Ticker ignored = searchAfterMetric.start()) { return super.searchAfter(after, query, filter, n, sort, doDocScores, doMaxScore); } }
@Override public TopDocs searchAfter(ScoreDoc after, Query query, Filter filter, int n) throws IOException { try (Ticker ignored = searchAfterMetric.start()) { return super.searchAfter(after, query, filter, n); } }
private void fetchMoreResult() { TopDocs topDocs = null; try { IndexSearcher searcher = queryContext.getSearcher(); if (queryContext.getSort() == null) topDocs = searcher.searchAfter(scoreDocs[scoreDocs.length - 1], query, PAGE_SIZE); else topDocs = searcher.searchAfter(scoreDocs[scoreDocs.length - 1], query, PAGE_SIZE, queryContext.getSort()); scoreDocs = topDocs.scoreDocs; } catch (IOException e) { OLogManager.instance().error(this, "Error on fetching document by query '%s' to Lucene index", e, query); } }
public static class RestoreRequest extends ServiceDocument { URI backupFile; static final String KIND = Utils.buildKind(RestoreRequest.class); }
private TopDocs searchOperations(ScoreDoc after) throws IOException { final Query rangeQuery = LongPoint.newRangeQuery(SeqNoFieldMapper.NAME, Math.max(fromSeqNo, lastSeenSeqNo), toSeqNo); final Sort sortedBySeqNoThenByTerm = new Sort( new SortField(SeqNoFieldMapper.NAME, SortField.Type.LONG), new SortField(SeqNoFieldMapper.PRIMARY_TERM_NAME, SortField.Type.LONG, true) ); return indexSearcher.searchAfter(after, rangeQuery, searchBatchSize, sortedBySeqNoThenByTerm); }
private TopDocs searchOperations(ScoreDoc after) throws IOException { final Query rangeQuery = LongPoint.newRangeQuery(SeqNoFieldMapper.NAME, Math.max(fromSeqNo, lastSeenSeqNo), toSeqNo); final Sort sortedBySeqNoThenByTerm = new Sort( new SortField(SeqNoFieldMapper.NAME, SortField.Type.LONG), new SortField(SeqNoFieldMapper.PRIMARY_TERM_NAME, SortField.Type.LONG, true) ); return indexSearcher.searchAfter(after, rangeQuery, searchBatchSize, sortedBySeqNoThenByTerm); }