@Test public void testLookup() throws IOException { addText(FIELD, "term1 term2"); init(false); List<String> suggestions = getSuggestions(FIELD, "t", 10); assertThat(suggestions, Matchers.containsInAnyOrder("term1", "term2")); data.close(); }
public List<Lookup.LookupResult> lookup(final String field, final String prefix, final int resultSize) { lock.readLock().lock(); try { WFSTCompletionLookup lookup = lookups.get(field); if (lookup == null) { logger.log(Level.WARNING, "No WFST for field {0} in {1}", new Object[] {field, suggesterDir}); return Collections.emptyList(); } return lookup.lookup(prefix, false, resultSize); } catch (IOException e) { logger.log(Level.WARNING, "Could not perform lookup in {0} for {1}:{2}", new Object[] {suggesterDir, field, prefix}); } finally { lock.readLock().unlock(); } return Collections.emptyList(); }
SuggesterProjectData implements Closeable { public List<Lookup.LookupResult> lookup(final String field, final String prefix, final int resultSize) { lock.readLock().lock(); try { WFSTCompletionLookup lookup = lookups.get(field); if (lookup == null) { logger.log(Level.WARNING, "No WFST for field {0} in {1}", new Object[] {field, suggesterDir}); return Collections.emptyList(); } return lookup.lookup(prefix, false, resultSize); } catch (IOException e) { logger.log(Level.WARNING, "Could not perform lookup in {0} for {1}:{2}", new Object[] {suggesterDir, field, prefix}); } finally { lock.readLock().unlock(); } return Collections.emptyList(); } }
SuggesterProjectData implements Closeable { public List<Lookup.LookupResult> lookup(final String field, final String prefix, final int resultSize) { lock.readLock().lock(); try { WFSTCompletionLookup lookup = lookups.get(field); if (lookup == null) { logger.log(Level.WARNING, "No WFST for field {0} in {1}", new Object[] {field, suggesterDir}); return Collections.emptyList(); } return lookup.lookup(prefix, false, resultSize); } catch (IOException e) { logger.log(Level.WARNING, "Could not perform lookup in {0} for {1}:{2}", new Object[] {suggesterDir, field, prefix}); } finally { lock.readLock().unlock(); } return Collections.emptyList(); } SuggesterProjectData(
            final Directory indexDir,
            final Path suggesterDir,
            final boolean allowMostPopular,
            final Set<String> fields
    ); }
SuggesterProjectData implements Closeable { public List<Lookup.LookupResult> lookup(final String field, final String prefix, final int resultSize) { lock.readLock().lock(); try { WFSTCompletionLookup lookup = lookups.get(field); if (lookup == null) { logger.log(Level.WARNING, "No WFST for field {0} in {1}", new Object[] {field, suggesterDir}); return Collections.emptyList(); } return lookup.lookup(prefix, false, resultSize); } catch (IOException e) { logger.log(Level.WARNING, "Could not perform lookup in {0} for {1}:{2}", new Object[] {suggesterDir, field, prefix}); } finally { lock.readLock().unlock(); } return Collections.emptyList(); } SuggesterProjectData(
            final Directory indexDir,
            final Path suggesterDir,
            final boolean allowMostPopular,
            final Set<String> fields
    ); void init(); void rebuild(); List<Lookup.LookupResult> lookup(final String field, final String prefix, final int resultSize); void remove(); void incrementSearchCount(final Term term); boolean incrementSearchCount(final Term term, final int value); PopularityCounter getSearchCounts(final String field); @Override void close(); boolean tryLock(); void unlock(); List<Entry<BytesRef, Integer>> getSearchCountsSorted(final String field, int page, int pageSize); @Override String toString(); }
SuggesterProjectData implements Closeable { public List<Lookup.LookupResult> lookup(final String field, final String prefix, final int resultSize) { lock.readLock().lock(); try { WFSTCompletionLookup lookup = lookups.get(field); if (lookup == null) { logger.log(Level.WARNING, "No WFST for field {0} in {1}", new Object[] {field, suggesterDir}); return Collections.emptyList(); } return lookup.lookup(prefix, false, resultSize); } catch (IOException e) { logger.log(Level.WARNING, "Could not perform lookup in {0} for {1}:{2}", new Object[] {suggesterDir, field, prefix}); } finally { lock.readLock().unlock(); } return Collections.emptyList(); } SuggesterProjectData(
            final Directory indexDir,
            final Path suggesterDir,
            final boolean allowMostPopular,
            final Set<String> fields
    ); void init(); void rebuild(); List<Lookup.LookupResult> lookup(final String field, final String prefix, final int resultSize); void remove(); void incrementSearchCount(final Term term); boolean incrementSearchCount(final Term term, final int value); PopularityCounter getSearchCounts(final String field); @Override void close(); boolean tryLock(); void unlock(); List<Entry<BytesRef, Integer>> getSearchCountsSorted(final String field, int page, int pageSize); @Override String toString();  }