Example usage for org.apache.lucene.search.suggest FileDictionary DEFAULT_FIELD_DELIMITER

List of usage examples for org.apache.lucene.search.suggest FileDictionary DEFAULT_FIELD_DELIMITER

Introduction

In this page you can find the example usage for org.apache.lucene.search.suggest FileDictionary DEFAULT_FIELD_DELIMITER.

Prototype

String DEFAULT_FIELD_DELIMITER

To view the source code for org.apache.lucene.search.suggest FileDictionary DEFAULT_FIELD_DELIMITER.

Click Source Link

Document

Tab-delimited fields are most common thus the default, but one can override this via the constructor

Usage

From source file:org.apache.solr.spelling.suggest.FileDictionaryFactory.java

License:Apache License

@Override
public Dictionary create(SolrCore core, SolrIndexSearcher searcher) {
    if (params == null) {
        // should not happen; implies setParams was not called
        throw new IllegalStateException("Value of params not set");
    }//from   w  ww .  ja v  a 2s .  c om

    String sourceLocation = (String) params.get(Suggester.LOCATION);

    if (sourceLocation == null) {
        throw new IllegalArgumentException(
                Suggester.LOCATION + " parameter is mandatory for using FileDictionary");
    }

    String fieldDelimiter = (params.get(FIELD_DELIMITER) != null) ? (String) params.get(FIELD_DELIMITER)
            : FileDictionary.DEFAULT_FIELD_DELIMITER;

    try {
        return new FileDictionary(new InputStreamReader(core.getResourceLoader().openResource(sourceLocation),
                StandardCharsets.UTF_8), fieldDelimiter);
    } catch (IOException e) {
        throw new RuntimeException();
    }
}