Example usage for org.apache.lucene.search.suggest DocumentDictionary DocumentDictionary

List of usage examples for org.apache.lucene.search.suggest DocumentDictionary DocumentDictionary

Introduction

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

Prototype

public DocumentDictionary(IndexReader reader, String field, String weightField, String payloadField) 

Source Link

Document

Creates a new dictionary with the contents of the fields named field for the terms, weightField for the weights that will be used for the the corresponding terms and payloadField for the corresponding payloads for the entry.

Usage

From source file:org.apache.solr.spelling.suggest.DocumentDictionaryFactory.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");
    }/* w w  w  . java 2s.  c o m*/
    String field = (String) params.get(FIELD);
    String weightField = (String) params.get(WEIGHT_FIELD);
    String payloadField = (String) params.get(PAYLOAD_FIELD);

    if (field == null) {
        throw new IllegalArgumentException(FIELD + " is a mandatory parameter");
    }
    if (weightField == null) {
        throw new IllegalArgumentException(WEIGHT_FIELD + " is a mandatory parameter");
    }

    return new DocumentDictionary(searcher.getIndexReader(), field, weightField, payloadField);
}