Search in sources :

Example 1 with LowerCaseFilterFactory

use of org.apache.lucene.analysis.core.LowerCaseFilterFactory in project lucene-solr by apache.

the class MultiTermTest method testMultiFound.

@Test
public void testMultiFound() {
    SchemaField field = h.getCore().getLatestSchema().getField("content_multi");
    Analyzer analyzer = ((TextField) field.getType()).getMultiTermAnalyzer();
    assertTrue(analyzer instanceof TokenizerChain);
    assertTrue(((TokenizerChain) analyzer).getTokenizerFactory() instanceof WhitespaceTokenizerFactory);
    TokenizerChain tc = (TokenizerChain) analyzer;
    for (TokenFilterFactory factory : tc.getTokenFilterFactories()) {
        assertTrue((factory instanceof ASCIIFoldingFilterFactory) || (factory instanceof LowerCaseFilterFactory));
    }
    analyzer = field.getType().getIndexAnalyzer();
    assertTrue(analyzer instanceof TokenizerChain);
    assertTrue(((TokenizerChain) analyzer).getTokenizerFactory() instanceof WhitespaceTokenizerFactory);
    tc = (TokenizerChain) analyzer;
    for (TokenFilterFactory factory : tc.getTokenFilterFactories()) {
        assertTrue((factory instanceof ASCIIFoldingFilterFactory) || (factory instanceof TrimFilterFactory));
    }
    assertTrue(tc.getCharFilterFactories().length == 0);
}
Also used : TokenizerChain(org.apache.solr.analysis.TokenizerChain) ASCIIFoldingFilterFactory(org.apache.lucene.analysis.miscellaneous.ASCIIFoldingFilterFactory) LowerCaseFilterFactory(org.apache.lucene.analysis.core.LowerCaseFilterFactory) TrimFilterFactory(org.apache.lucene.analysis.miscellaneous.TrimFilterFactory) Analyzer(org.apache.lucene.analysis.Analyzer) WhitespaceTokenizerFactory(org.apache.lucene.analysis.core.WhitespaceTokenizerFactory) TokenFilterFactory(org.apache.lucene.analysis.util.TokenFilterFactory) Test(org.junit.Test)

Example 2 with LowerCaseFilterFactory

use of org.apache.lucene.analysis.core.LowerCaseFilterFactory in project lucene-solr by apache.

the class MultiTermTest method testDefaultCopiedToMulti.

@Test
public void testDefaultCopiedToMulti() {
    SchemaField field = h.getCore().getLatestSchema().getField("content_ws");
    Analyzer analyzer = ((TextField) field.getType()).getMultiTermAnalyzer();
    assertTrue(analyzer instanceof TokenizerChain);
    assertTrue(((TokenizerChain) analyzer).getTokenizerFactory() instanceof KeywordTokenizerFactory);
    TokenizerChain tc = (TokenizerChain) analyzer;
    for (TokenFilterFactory factory : tc.getTokenFilterFactories()) {
        assertTrue((factory instanceof ASCIIFoldingFilterFactory) || (factory instanceof LowerCaseFilterFactory));
    }
    assertTrue(tc.getCharFilterFactories().length == 0);
}
Also used : TokenizerChain(org.apache.solr.analysis.TokenizerChain) ASCIIFoldingFilterFactory(org.apache.lucene.analysis.miscellaneous.ASCIIFoldingFilterFactory) LowerCaseFilterFactory(org.apache.lucene.analysis.core.LowerCaseFilterFactory) Analyzer(org.apache.lucene.analysis.Analyzer) TokenFilterFactory(org.apache.lucene.analysis.util.TokenFilterFactory) KeywordTokenizerFactory(org.apache.lucene.analysis.core.KeywordTokenizerFactory) Test(org.junit.Test)

Example 3 with LowerCaseFilterFactory

use of org.apache.lucene.analysis.core.LowerCaseFilterFactory in project lucene-solr by apache.

the class MultiTermTest method testQueryCopiedToMulti.

@Test
public void testQueryCopiedToMulti() {
    SchemaField field = h.getCore().getLatestSchema().getField("content_charfilter");
    Analyzer analyzer = ((TextField) field.getType()).getMultiTermAnalyzer();
    assertTrue(analyzer instanceof TokenizerChain);
    assertTrue(((TokenizerChain) analyzer).getTokenizerFactory() instanceof KeywordTokenizerFactory);
    TokenizerChain tc = (TokenizerChain) analyzer;
    for (TokenFilterFactory factory : tc.getTokenFilterFactories()) {
        assertTrue(factory instanceof LowerCaseFilterFactory);
    }
    assertTrue(tc.getCharFilterFactories().length == 1);
    assertTrue(tc.getCharFilterFactories()[0] instanceof MappingCharFilterFactory);
}
Also used : TokenizerChain(org.apache.solr.analysis.TokenizerChain) LowerCaseFilterFactory(org.apache.lucene.analysis.core.LowerCaseFilterFactory) MappingCharFilterFactory(org.apache.lucene.analysis.charfilter.MappingCharFilterFactory) Analyzer(org.apache.lucene.analysis.Analyzer) TokenFilterFactory(org.apache.lucene.analysis.util.TokenFilterFactory) KeywordTokenizerFactory(org.apache.lucene.analysis.core.KeywordTokenizerFactory) Test(org.junit.Test)

Aggregations

Analyzer (org.apache.lucene.analysis.Analyzer)3 LowerCaseFilterFactory (org.apache.lucene.analysis.core.LowerCaseFilterFactory)3 TokenFilterFactory (org.apache.lucene.analysis.util.TokenFilterFactory)3 TokenizerChain (org.apache.solr.analysis.TokenizerChain)3 Test (org.junit.Test)3 KeywordTokenizerFactory (org.apache.lucene.analysis.core.KeywordTokenizerFactory)2 ASCIIFoldingFilterFactory (org.apache.lucene.analysis.miscellaneous.ASCIIFoldingFilterFactory)2 MappingCharFilterFactory (org.apache.lucene.analysis.charfilter.MappingCharFilterFactory)1 WhitespaceTokenizerFactory (org.apache.lucene.analysis.core.WhitespaceTokenizerFactory)1 TrimFilterFactory (org.apache.lucene.analysis.miscellaneous.TrimFilterFactory)1