@Test public void initAfterChangingIndexTest() throws IOException { addText(FIELD, "term"); init(false); addText(FIELD, "term2"); data.init(); assertThat(getSuggestions(FIELD, "t", 2), containsInAnyOrder("term", "term2")); }
public void init() throws IOException { lock.writeLock().lock(); try { long commitVersion = getCommitVersion(); if (hasStoredData() && commitVersion == getDataVersion()) { loadStoredWFSTs(); } else { createSuggesterDir(); build(); } if (allowMostPopular) { initSearchCountMap(); } storeDataVersion(commitVersion); } finally { lock.writeLock().unlock(); } }
SuggesterProjectData implements Closeable { public void init() throws IOException { lock.writeLock().lock(); try { long commitVersion = getCommitVersion(); if (hasStoredData() && commitVersion == getDataVersion()) { loadStoredWFSTs(); } else { createSuggesterDir(); build(); } if (allowMostPopular) { initSearchCountMap(); } storeDataVersion(commitVersion); } finally { lock.writeLock().unlock(); } } }
SuggesterProjectData implements Closeable { public void init() throws IOException { lock.writeLock().lock(); try { long commitVersion = getCommitVersion(); if (hasStoredData() && commitVersion == getDataVersion()) { loadStoredWFSTs(); } else { createSuggesterDir(); build(); } if (allowMostPopular) { initSearchCountMap(); } storeDataVersion(commitVersion); } finally { lock.writeLock().unlock(); } } SuggesterProjectData(
            final Directory indexDir,
            final Path suggesterDir,
            final boolean allowMostPopular,
            final Set<String> fields
    ); }
SuggesterProjectData implements Closeable { public void init() throws IOException { lock.writeLock().lock(); try { long commitVersion = getCommitVersion(); if (hasStoredData() && commitVersion == getDataVersion()) { loadStoredWFSTs(); } else { createSuggesterDir(); build(); } if (allowMostPopular) { initSearchCountMap(); } storeDataVersion(commitVersion); } finally { lock.writeLock().unlock(); } } 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 void init() throws IOException { lock.writeLock().lock(); try { long commitVersion = getCommitVersion(); if (hasStoredData() && commitVersion == getDataVersion()) { loadStoredWFSTs(); } else { createSuggesterDir(); build(); } if (allowMostPopular) { initSearchCountMap(); } storeDataVersion(commitVersion); } finally { lock.writeLock().unlock(); } } 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();  }