Search in sources :

Example 11 with MultiTermAwareComponent

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

the class TestFactories method doTestCharFilter.

private void doTestCharFilter(String charfilter) throws IOException {
    Class<? extends CharFilterFactory> factoryClazz = CharFilterFactory.lookupClass(charfilter);
    CharFilterFactory factory = (CharFilterFactory) 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 a tokenizer or tokenfilter here, this makes no sense
            assertTrue(mtc instanceof CharFilterFactory);
        }
        // beast it just a little, it shouldnt throw exceptions:
        // (it should have thrown them in initialize)
        Analyzer a = new FactoryAnalyzer(assertingTokenizer, null, factory);
        checkRandomData(random(), a, 20, 20, false, false);
        a.close();
    }
}
Also used : MultiTermAwareComponent(org.apache.lucene.analysis.util.MultiTermAwareComponent) CharFilterFactory(org.apache.lucene.analysis.util.CharFilterFactory) AbstractAnalysisFactory(org.apache.lucene.analysis.util.AbstractAnalysisFactory) Analyzer(org.apache.lucene.analysis.Analyzer)

Aggregations

MultiTermAwareComponent (org.apache.lucene.analysis.util.MultiTermAwareComponent)11 Analyzer (org.apache.lucene.analysis.Analyzer)6 AbstractAnalysisFactory (org.apache.lucene.analysis.util.AbstractAnalysisFactory)6 CharFilterFactory (org.apache.lucene.analysis.util.CharFilterFactory)6 TokenFilterFactory (org.apache.lucene.analysis.util.TokenFilterFactory)5 TokenStream (org.apache.lucene.analysis.TokenStream)2 TokenizerFactory (org.apache.lucene.analysis.util.TokenizerFactory)2 HashMap (java.util.HashMap)1 CannedTokenStream (org.apache.lucene.analysis.CannedTokenStream)1 Token (org.apache.lucene.analysis.Token)1