@Test @SuppressWarnings("unchecked") public void testOnSearch() throws IOException { SuggesterTestData t = initSuggester(); Query q = new BooleanQuery.Builder() .add(new TermQuery(new Term("test", "term1")), BooleanClause.Occur.MUST) .add(new TermQuery(new Term("test", "term3")), BooleanClause.Occur.MUST) .build(); t.s.onSearch(Collections.singleton("test"), q); List<Entry<BytesRef, Integer>> res = t.s.getSearchCounts("test", "test", 0, 10); assertThat(res, containsInAnyOrder(new SimpleEntry<>(new BytesRef("term1"), 1), new SimpleEntry<>(new BytesRef("term3"), 1))); t.close(); }
public void onSearch(final Iterable<String> projects, final Query query) { if (!allowMostPopular || projects == null) { return; } try { List<Term> terms = SuggesterUtils.intoTerms(query); if (!projectsEnabled) { for (Term t : terms) { SuggesterProjectData data = projectData.get(PROJECTS_DISABLED_KEY); if (data != null) { data.incrementSearchCount(t); } } } else { for (String project : projects) { for (Term t : terms) { SuggesterProjectData data = projectData.get(project); if (data != null) { data.incrementSearchCount(t); } } } } } catch (Exception e) { logger.log(Level.FINE, String.format("Could not update search count map%s", projectsEnabled ? " for projects: " + projects : ""), e); } }
Suggester implements Closeable { public void onSearch(final Iterable<String> projects, final Query query) { if (!allowMostPopular || projects == null) { return; } try { List<Term> terms = SuggesterUtils.intoTerms(query); if (!projectsEnabled) { for (Term t : terms) { SuggesterProjectData data = projectData.get(PROJECTS_DISABLED_KEY); if (data != null) { data.incrementSearchCount(t); } } } else { for (String project : projects) { for (Term t : terms) { SuggesterProjectData data = projectData.get(project); if (data != null) { data.incrementSearchCount(t); } } } } } catch (Exception e) { logger.log(Level.FINE, String.format("Could not update search count map%s", projectsEnabled ? " for projects: " + projects : ""), e); } } }
Suggester implements Closeable { public void onSearch(final Iterable<String> projects, final Query query) { if (!allowMostPopular || projects == null) { return; } try { List<Term> terms = SuggesterUtils.intoTerms(query); if (!projectsEnabled) { for (Term t : terms) { SuggesterProjectData data = projectData.get(PROJECTS_DISABLED_KEY); if (data != null) { data.incrementSearchCount(t); } } } else { for (String project : projects) { for (Term t : terms) { SuggesterProjectData data = projectData.get(project); if (data != null) { data.incrementSearchCount(t); } } } } } catch (Exception e) { logger.log(Level.FINE, String.format("Could not update search count map%s", projectsEnabled ? " for projects: " + projects : ""), e); } } Suggester(
            final File suggesterDir,
            final int resultSize,
            final Duration awaitTerminationTime,
            final boolean allowMostPopular,
            final boolean projectsEnabled,
            final Set<String> allowedFields,
            final int timeThreshold,
            final int rebuildParallelismLevel,
            MeterRegistry registry); }
Suggester implements Closeable { public void onSearch(final Iterable<String> projects, final Query query) { if (!allowMostPopular || projects == null) { return; } try { List<Term> terms = SuggesterUtils.intoTerms(query); if (!projectsEnabled) { for (Term t : terms) { SuggesterProjectData data = projectData.get(PROJECTS_DISABLED_KEY); if (data != null) { data.incrementSearchCount(t); } } } else { for (String project : projects) { for (Term t : terms) { SuggesterProjectData data = projectData.get(project); if (data != null) { data.incrementSearchCount(t); } } } } } catch (Exception e) { logger.log(Level.FINE, String.format("Could not update search count map%s", projectsEnabled ? " for projects: " + projects : ""), e); } } Suggester(
            final File suggesterDir,
            final int resultSize,
            final Duration awaitTerminationTime,
            final boolean allowMostPopular,
            final boolean projectsEnabled,
            final Set<String> allowedFields,
            final int timeThreshold,
            final int rebuildParallelismLevel,
            MeterRegistry registry); void init(final Collection<NamedIndexDir> luceneIndexes); void waitForInit(long timeout, TimeUnit unit); void rebuild(final Collection<NamedIndexDir> indexDirs); void waitForRebuild(long timeout, TimeUnit unit); void remove(final Iterable<String> names); Suggestions search(
            final List<NamedIndexReader> indexReaders,
            final SuggesterQuery suggesterQuery,
            final Query query
    ); void onSearch(final Iterable<String> projects, final Query query); void setResultSize(final int resultSize); void setAwaitTerminationTime(final Duration awaitTerminationTime); boolean increaseSearchCount(final String project, final Term term, final int value, final boolean waitForLock); List<Entry<BytesRef, Integer>> getSearchCounts(
            final String project,
            final String field,
            final int page,
            final int pageSize
    ); @Override void close(); }
Suggester implements Closeable { public void onSearch(final Iterable<String> projects, final Query query) { if (!allowMostPopular || projects == null) { return; } try { List<Term> terms = SuggesterUtils.intoTerms(query); if (!projectsEnabled) { for (Term t : terms) { SuggesterProjectData data = projectData.get(PROJECTS_DISABLED_KEY); if (data != null) { data.incrementSearchCount(t); } } } else { for (String project : projects) { for (Term t : terms) { SuggesterProjectData data = projectData.get(project); if (data != null) { data.incrementSearchCount(t); } } } } } catch (Exception e) { logger.log(Level.FINE, String.format("Could not update search count map%s", projectsEnabled ? " for projects: " + projects : ""), e); } } Suggester(
            final File suggesterDir,
            final int resultSize,
            final Duration awaitTerminationTime,
            final boolean allowMostPopular,
            final boolean projectsEnabled,
            final Set<String> allowedFields,
            final int timeThreshold,
            final int rebuildParallelismLevel,
            MeterRegistry registry); void init(final Collection<NamedIndexDir> luceneIndexes); void waitForInit(long timeout, TimeUnit unit); void rebuild(final Collection<NamedIndexDir> indexDirs); void waitForRebuild(long timeout, TimeUnit unit); void remove(final Iterable<String> names); Suggestions search(
            final List<NamedIndexReader> indexReaders,
            final SuggesterQuery suggesterQuery,
            final Query query
    ); void onSearch(final Iterable<String> projects, final Query query); void setResultSize(final int resultSize); void setAwaitTerminationTime(final Duration awaitTerminationTime); boolean increaseSearchCount(final String project, final Term term, final int value, final boolean waitForLock); List<Entry<BytesRef, Integer>> getSearchCounts(
            final String project,
            final String field,
            final int page,
            final int pageSize
    ); @Override void close();  }