@Test public void suggesterWildcardQueryTest() { List<LookupResultItem> suggestions = searcher.suggest(new TermQuery(new Term("test", "test")), "test", new SuggesterWildcardQuery(new Term("test", "?pengrok")), k -> 0); List<String> tokens = suggestions.stream().map(LookupResultItem::getPhrase).collect(Collectors.toList()); assertThat(tokens, contains("opengrok")); }
public List<LookupResultItem> suggest( final Query query, final String project, final SuggesterQuery suggesterQuery, final PopularityCounter popularityCounter ) { List<LookupResultItem> results = new ArrayList<>(resultSize * leafContexts.size()); Query rewrittenQuery = null; try { if (query != null) { rewrittenQuery = query.rewrite(getIndexReader()); } } catch (IOException e) { logger.log(Level.WARNING, "Could not rewrite query", e); return results; } for (LeafReaderContext context : this.leafContexts) { if (interrupted) { break; } try { results.addAll(suggest(rewrittenQuery, context, project, suggesterQuery, popularityCounter)); } catch (IOException e) { logger.log(Level.WARNING, "Cannot perform suggester search", e); } } if (results.size() > resultSize) { return SuggesterUtils.combineResults(results, resultSize); } return results; }
SuggesterSearcher extends IndexSearcher { public List<LookupResultItem> suggest( final Query query, final String project, final SuggesterQuery suggesterQuery, final PopularityCounter popularityCounter ) { List<LookupResultItem> results = new ArrayList<>(resultSize * leafContexts.size()); Query rewrittenQuery = null; try { if (query != null) { rewrittenQuery = query.rewrite(getIndexReader()); } } catch (IOException e) { logger.log(Level.WARNING, "Could not rewrite query", e); return results; } for (LeafReaderContext context : this.leafContexts) { if (interrupted) { break; } try { results.addAll(suggest(rewrittenQuery, context, project, suggesterQuery, popularityCounter)); } catch (IOException e) { logger.log(Level.WARNING, "Cannot perform suggester search", e); } } if (results.size() > resultSize) { return SuggesterUtils.combineResults(results, resultSize); } return results; } }
SuggesterSearcher extends IndexSearcher { public List<LookupResultItem> suggest( final Query query, final String project, final SuggesterQuery suggesterQuery, final PopularityCounter popularityCounter ) { List<LookupResultItem> results = new ArrayList<>(resultSize * leafContexts.size()); Query rewrittenQuery = null; try { if (query != null) { rewrittenQuery = query.rewrite(getIndexReader()); } } catch (IOException e) { logger.log(Level.WARNING, "Could not rewrite query", e); return results; } for (LeafReaderContext context : this.leafContexts) { if (interrupted) { break; } try { results.addAll(suggest(rewrittenQuery, context, project, suggesterQuery, popularityCounter)); } catch (IOException e) { logger.log(Level.WARNING, "Cannot perform suggester search", e); } } if (results.size() > resultSize) { return SuggesterUtils.combineResults(results, resultSize); } return results; } SuggesterSearcher(final IndexReader reader, final int resultSize); }
SuggesterSearcher extends IndexSearcher { public List<LookupResultItem> suggest( final Query query, final String project, final SuggesterQuery suggesterQuery, final PopularityCounter popularityCounter ) { List<LookupResultItem> results = new ArrayList<>(resultSize * leafContexts.size()); Query rewrittenQuery = null; try { if (query != null) { rewrittenQuery = query.rewrite(getIndexReader()); } } catch (IOException e) { logger.log(Level.WARNING, "Could not rewrite query", e); return results; } for (LeafReaderContext context : this.leafContexts) { if (interrupted) { break; } try { results.addAll(suggest(rewrittenQuery, context, project, suggesterQuery, popularityCounter)); } catch (IOException e) { logger.log(Level.WARNING, "Cannot perform suggester search", e); } } if (results.size() > resultSize) { return SuggesterUtils.combineResults(results, resultSize); } return results; } SuggesterSearcher(final IndexReader reader, final int resultSize); List<LookupResultItem> suggest(
            final Query query,
            final String project,
            final SuggesterQuery suggesterQuery,
            final PopularityCounter popularityCounter
    ); }
SuggesterSearcher extends IndexSearcher { public List<LookupResultItem> suggest( final Query query, final String project, final SuggesterQuery suggesterQuery, final PopularityCounter popularityCounter ) { List<LookupResultItem> results = new ArrayList<>(resultSize * leafContexts.size()); Query rewrittenQuery = null; try { if (query != null) { rewrittenQuery = query.rewrite(getIndexReader()); } } catch (IOException e) { logger.log(Level.WARNING, "Could not rewrite query", e); return results; } for (LeafReaderContext context : this.leafContexts) { if (interrupted) { break; } try { results.addAll(suggest(rewrittenQuery, context, project, suggesterQuery, popularityCounter)); } catch (IOException e) { logger.log(Level.WARNING, "Cannot perform suggester search", e); } } if (results.size() > resultSize) { return SuggesterUtils.combineResults(results, resultSize); } return results; } SuggesterSearcher(final IndexReader reader, final int resultSize); List<LookupResultItem> suggest(
            final Query query,
            final String project,
            final SuggesterQuery suggesterQuery,
            final PopularityCounter popularityCounter
    ); static final int TERM_ALREADY_SEARCHED_MULTIPLIER; }