Example usage for org.apache.lucene.search.suggest.fst WFSTCompletionLookup build

List of usage examples for org.apache.lucene.search.suggest.fst WFSTCompletionLookup build

Introduction

In this page you can find the example usage for org.apache.lucene.search.suggest.fst WFSTCompletionLookup build.

Prototype

@Override
    public void build(InputIterator iterator) throws IOException 

Source Link

Usage

From source file:org.opengrok.suggest.SuggesterProjectData.java

License:Open Source License

private WFSTCompletionLookup build(final IndexReader indexReader, final String field) throws IOException {
    WFSTInputIterator iterator = new WFSTInputIterator(
            new LuceneDictionary(indexReader, field).getEntryIterator(), indexReader, field,
            getSearchCounts(field));/*from ww  w . j a  v a  2s .c  o m*/

    WFSTCompletionLookup lookup = createWFST();
    lookup.build(iterator);

    double averageLength = (double) iterator.termLengthAccumulator / lookup.getCount();
    averageLengths.put(field, averageLength);

    return lookup;
}