List of usage examples for org.apache.lucene.search.suggest.analyzing FuzzySuggester DEFAULT_UNICODE_AWARE
boolean DEFAULT_UNICODE_AWARE
To view the source code for org.apache.lucene.search.suggest.analyzing FuzzySuggester DEFAULT_UNICODE_AWARE.
Click Source Link
From source file:org.apache.solr.spelling.suggest.fst.FuzzyLookupFactory.java
License:Apache License
@Override public Lookup create(NamedList params, SolrCore core) { // mandatory parameter Object fieldTypeName = params.get(AnalyzingLookupFactory.QUERY_ANALYZER); if (fieldTypeName == null) { throw new IllegalArgumentException( "Error in configuration: " + AnalyzingLookupFactory.QUERY_ANALYZER + " parameter is mandatory"); }//from w w w. ja v a 2 s. c o m // retrieve index and query analyzers for the field FieldType ft = core.getLatestSchema().getFieldTypeByName(fieldTypeName.toString()); Analyzer indexAnalyzer = ft.getAnalyzer(); Analyzer queryAnalyzer = ft.getQueryAnalyzer(); // optional parameters boolean exactMatchFirst = (params.get(AnalyzingLookupFactory.EXACT_MATCH_FIRST) != null) ? Boolean.valueOf(params.get(AnalyzingLookupFactory.EXACT_MATCH_FIRST).toString()) : true; boolean preserveSep = (params.get(AnalyzingLookupFactory.PRESERVE_SEP) != null) ? Boolean.valueOf(params.get(AnalyzingLookupFactory.PRESERVE_SEP).toString()) : true; int options = 0; if (exactMatchFirst) { options |= FuzzySuggester.EXACT_FIRST; } if (preserveSep) { options |= FuzzySuggester.PRESERVE_SEP; } int maxSurfaceFormsPerAnalyzedForm = (params.get(AnalyzingLookupFactory.MAX_SURFACE_FORMS) != null) ? Integer.parseInt(params.get(AnalyzingLookupFactory.MAX_SURFACE_FORMS).toString()) : 256; int maxGraphExpansions = (params.get(AnalyzingLookupFactory.MAX_EXPANSIONS) != null) ? Integer.parseInt(params.get(AnalyzingLookupFactory.MAX_EXPANSIONS).toString()) : -1; boolean preservePositionIncrements = params.get(AnalyzingLookupFactory.PRESERVE_POSITION_INCREMENTS) != null ? Boolean.valueOf(params.get(AnalyzingLookupFactory.PRESERVE_POSITION_INCREMENTS).toString()) : false; int maxEdits = (params.get(MAX_EDITS) != null) ? Integer.parseInt(params.get(MAX_EDITS).toString()) : FuzzySuggester.DEFAULT_MAX_EDITS; boolean transpositions = (params.get(TRANSPOSITIONS) != null) ? Boolean.parseBoolean(params.get(TRANSPOSITIONS).toString()) : FuzzySuggester.DEFAULT_TRANSPOSITIONS; int nonFuzzyPrefix = (params.get(NON_FUZZY_PREFIX) != null) ? Integer.parseInt(params.get(NON_FUZZY_PREFIX).toString()) : FuzzySuggester.DEFAULT_NON_FUZZY_PREFIX; int minFuzzyLength = (params.get(MIN_FUZZY_LENGTH) != null) ? Integer.parseInt(params.get(MIN_FUZZY_LENGTH).toString()) : FuzzySuggester.DEFAULT_MIN_FUZZY_LENGTH; boolean unicodeAware = (params.get(UNICODE_AWARE) != null) ? Boolean.valueOf(params.get(UNICODE_AWARE).toString()) : FuzzySuggester.DEFAULT_UNICODE_AWARE; return new FuzzySuggester(indexAnalyzer, queryAnalyzer, options, maxSurfaceFormsPerAnalyzedForm, maxGraphExpansions, preservePositionIncrements, maxEdits, transpositions, nonFuzzyPrefix, minFuzzyLength, unicodeAware); }