use of org.apache.lucene.analysis.util.CharFilterFactory in project jackrabbit-oak 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();
}
use of org.apache.lucene.analysis.util.CharFilterFactory in project jackrabbit-oak 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;
}
use of org.apache.lucene.analysis.util.CharFilterFactory in project jackrabbit-oak by apache.
the class NodeStateAnalyzerFactory method composeAnalyzer.
private Analyzer composeAnalyzer(NodeState state) {
TokenizerFactory tf = loadTokenizer(state.getChildNode(LuceneIndexConstants.ANL_TOKENIZER));
CharFilterFactory[] cfs = loadCharFilterFactories(state.getChildNode(LuceneIndexConstants.ANL_CHAR_FILTERS));
TokenFilterFactory[] tffs = loadTokenFilterFactories(state.getChildNode(LuceneIndexConstants.ANL_FILTERS));
return new TokenizerChain(cfs, tf, tffs);
}
use of org.apache.lucene.analysis.util.CharFilterFactory in project lucene-solr by apache.
the class CustomAnalyzer method initReaderForNormalization.
@Override
protected Reader initReaderForNormalization(String fieldName, Reader reader) {
for (CharFilterFactory charFilter : charFilters) {
if (charFilter instanceof MultiTermAwareComponent) {
charFilter = (CharFilterFactory) ((MultiTermAwareComponent) charFilter).getMultiTermComponent();
reader = charFilter.create(reader);
}
}
return reader;
}
use of org.apache.lucene.analysis.util.CharFilterFactory in project lucene-solr by apache.
the class TestFactories method doTestTokenizer.
private void doTestTokenizer(String tokenizer) throws IOException {
Class<? extends TokenizerFactory> factoryClazz = TokenizerFactory.lookupClass(tokenizer);
TokenizerFactory factory = (TokenizerFactory) initialize(factoryClazz);
if (factory != null) {
// if it implements MultiTermAware, sanity check its impl
if (factory instanceof MultiTermAwareComponent) {
AbstractAnalysisFactory mtc = ((MultiTermAwareComponent) factory).getMultiTermComponent();
assertNotNull(mtc);
// it's not ok to return e.g. a charfilter here: but a tokenizer could wrap a filter around it
assertFalse(mtc instanceof CharFilterFactory);
}
// beast it just a little, it shouldnt throw exceptions:
// (it should have thrown them in initialize)
Analyzer a = new FactoryAnalyzer(factory, null, null);
checkRandomData(random(), a, 20, 20, false, false);
a.close();
}
}
Aggregations