Search in sources :

Example 16 with CharFilterFactory

use of org.apache.lucene.analysis.util.CharFilterFactory in project jackrabbit-oak by apache.

the class NodeStateAnalyzerFactory method loadCharFilterFactories.

private CharFilterFactory[] loadCharFilterFactories(NodeState charFiltersState) {
    List<CharFilterFactory> result = newArrayList();
    //Need to read children in order
    Tree tree = TreeFactory.createReadOnlyTree(charFiltersState);
    for (Tree t : tree.getChildren()) {
        NodeState state = charFiltersState.getChildNode(t.getName());
        String factoryType = getFactoryType(state, t.getName());
        Map<String, String> args = convertNodeState(state);
        CharFilterFactory cf = CharFilterFactory.forName(factoryType, args);
        init(cf, state);
        result.add(cf);
    }
    return result.toArray(new CharFilterFactory[result.size()]);
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) CharFilterFactory(org.apache.lucene.analysis.util.CharFilterFactory) Tree(org.apache.jackrabbit.oak.api.Tree)

Example 17 with CharFilterFactory

use of org.apache.lucene.analysis.util.CharFilterFactory in project lucene-solr by apache.

the class CustomAnalyzer method toString.

@Override
public String toString() {
    final StringBuilder sb = new StringBuilder(getClass().getSimpleName()).append('(');
    for (final CharFilterFactory filter : charFilters) {
        sb.append(filter).append(',');
    }
    sb.append(tokenizer);
    for (final TokenFilterFactory filter : tokenFilters) {
        sb.append(',').append(filter);
    }
    return sb.append(')').toString();
}
Also used : CharFilterFactory(org.apache.lucene.analysis.util.CharFilterFactory) TokenFilterFactory(org.apache.lucene.analysis.util.TokenFilterFactory)

Example 18 with CharFilterFactory

use of org.apache.lucene.analysis.util.CharFilterFactory in project lucene-solr by apache.

the class TokenizerChain method initReaderForNormalization.

@Override
protected Reader initReaderForNormalization(String fieldName, Reader reader) {
    if (charFilters != null && charFilters.length > 0) {
        for (CharFilterFactory charFilter : charFilters) {
            if (charFilter instanceof MultiTermAwareComponent) {
                charFilter = (CharFilterFactory) ((MultiTermAwareComponent) charFilter).getMultiTermComponent();
                reader = charFilter.create(reader);
            }
        }
    }
    return reader;
}
Also used : MultiTermAwareComponent(org.apache.lucene.analysis.util.MultiTermAwareComponent) CharFilterFactory(org.apache.lucene.analysis.util.CharFilterFactory)

Example 19 with CharFilterFactory

use of org.apache.lucene.analysis.util.CharFilterFactory in project lucene-solr by apache.

the class TokenizerChain method initReader.

@Override
public Reader initReader(String fieldName, Reader reader) {
    if (charFilters != null && charFilters.length > 0) {
        Reader cs = reader;
        for (CharFilterFactory charFilter : charFilters) {
            cs = charFilter.create(cs);
        }
        reader = cs;
    }
    return reader;
}
Also used : CharFilterFactory(org.apache.lucene.analysis.util.CharFilterFactory) Reader(java.io.Reader)

Example 20 with CharFilterFactory

use of org.apache.lucene.analysis.util.CharFilterFactory in project lucene-solr by apache.

the class TokenizerChain method toString.

@Override
public String toString() {
    StringBuilder sb = new StringBuilder("TokenizerChain(");
    for (CharFilterFactory filter : charFilters) {
        sb.append(filter);
        sb.append(", ");
    }
    sb.append(tokenizer);
    for (TokenFilterFactory filter : filters) {
        sb.append(", ");
        sb.append(filter);
    }
    sb.append(')');
    return sb.toString();
}
Also used : CharFilterFactory(org.apache.lucene.analysis.util.CharFilterFactory) TokenFilterFactory(org.apache.lucene.analysis.util.TokenFilterFactory)

Aggregations

CharFilterFactory (org.apache.lucene.analysis.util.CharFilterFactory)26 TokenFilterFactory (org.apache.lucene.analysis.util.TokenFilterFactory)16 TokenizerFactory (org.apache.lucene.analysis.util.TokenizerFactory)12 Analyzer (org.apache.lucene.analysis.Analyzer)7 MultiTermAwareComponent (org.apache.lucene.analysis.util.MultiTermAwareComponent)6 TokenizerChain (org.apache.solr.analysis.TokenizerChain)5 Reader (java.io.Reader)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 AbstractAnalysisFactory (org.apache.lucene.analysis.util.AbstractAnalysisFactory)4 StringReader (java.io.StringReader)3 Map (java.util.Map)3 TokenStream (org.apache.lucene.analysis.TokenStream)3 Tokenizer (org.apache.lucene.analysis.Tokenizer)3 ResourceLoaderAware (org.apache.lucene.analysis.util.ResourceLoaderAware)3 SolrException (org.apache.solr.common.SolrException)3 JsonElement (com.google.gson.JsonElement)2 JsonObject (com.google.gson.JsonObject)2 IOException (java.io.IOException)2 KeywordAnalyzer (org.apache.lucene.analysis.core.KeywordAnalyzer)2