Java Code Examples for org.apache.lucene.analysis.util.AbstractAnalysisFactory

The following examples show how to use org.apache.lucene.analysis.util.AbstractAnalysisFactory. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public SimpleAnalyzer(boolean lowerCase) {
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put(PatternTokenizerFactory.PATTERN, PATTERN);
    parameters.put(PatternTokenizerFactory.GROUP, "0");
    parameters.put(AbstractAnalysisFactory.LUCENE_MATCH_VERSION_PARAM,
            version.name());
    tokenizerFactory = new PatternTokenizerFactory(parameters);
    if (lowerCase) {
        parameters = new HashMap<String, String>();
        parameters.put(AbstractAnalysisFactory.LUCENE_MATCH_VERSION_PARAM,
                version.name());
        lowerCaseFilterFactory = new LowerCaseFilterFactory(parameters);
    } else {
        lowerCaseFilterFactory = null;
    }
}
 
Example 2
public void add(Object current)
{
    if (!(current instanceof MultiTermAwareComponent))
        return;
    AbstractAnalysisFactory newComponent = ((MultiTermAwareComponent) current).getMultiTermComponent();
    if (newComponent instanceof TokenFilterFactory)
    {
        if (filters == null)
        {
            filters = new ArrayList<TokenFilterFactory>(2);
        }
        filters.add((TokenFilterFactory) newComponent);
    }
    else if (newComponent instanceof TokenizerFactory)
    {
        tokenizer = (TokenizerFactory) newComponent;
    }
    else if (newComponent instanceof CharFilterFactory)
    {
        if (charFilters == null)
        {
            charFilters = new ArrayList<CharFilterFactory>(1);
        }
        charFilters.add((CharFilterFactory) newComponent);

    }
    else
    {
        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown analysis component from MultiTermAwareComponent: " + newComponent);
    }
}
 
Example 3
Source Project: lucene-solr   Source File: CustomAnalyzer.java    License: Apache License 2.0 4 votes vote down vote up
private Map<String,String> applyDefaultParams(Map<String,String> map) {
  if (defaultMatchVersion.get() != null && !map.containsKey(AbstractAnalysisFactory.LUCENE_MATCH_VERSION_PARAM)) {
    map.put(AbstractAnalysisFactory.LUCENE_MATCH_VERSION_PARAM, defaultMatchVersion.get().toString());
  }
  return map;
}