use of org.apache.lucene.search.suggest.analyzing.FreeTextSuggester in project lucene-solr by apache.
the class FreeTextLookupFactory method create.
@Override
public Lookup create(NamedList params, SolrCore core) {
Object fieldTypeName = params.get(QUERY_ANALYZER);
if (fieldTypeName == null) {
throw new IllegalArgumentException("Error in configuration: " + QUERY_ANALYZER + " parameter is mandatory");
}
FieldType ft = core.getLatestSchema().getFieldTypeByName(fieldTypeName.toString());
if (ft == null) {
throw new IllegalArgumentException("Error in configuration: " + fieldTypeName.toString() + " is not defined in the schema");
}
Analyzer indexAnalyzer = ft.getIndexAnalyzer();
Analyzer queryAnalyzer = ft.getQueryAnalyzer();
int grams = (params.get(NGRAMS) != null) ? Integer.parseInt(params.get(NGRAMS).toString()) : FreeTextSuggester.DEFAULT_GRAMS;
byte separator = (params.get(SEPARATOR) != null) ? params.get(SEPARATOR).toString().getBytes(StandardCharsets.UTF_8)[0] : FreeTextSuggester.DEFAULT_SEPARATOR;
return new FreeTextSuggester(indexAnalyzer, queryAnalyzer, grams, separator);
}
Aggregations