List of usage examples for org.apache.lucene.search.suggest.fst WFSTCompletionLookup lookup
public List<LookupResult> lookup(CharSequence key, boolean onlyMorePopular, int num) throws IOException
From source file:org.opengrok.suggest.SuggesterProjectData.java
License:Open Source License
/** * Looks up the terms in the WFST data structure. * @param field term field/*from ww w. j ava 2 s .co m*/ * @param prefix prefix the returned terms must contain * @param resultSize number of terms to return * @return terms with highest score */ 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(); }