use of org.apache.lucene.analysis.core.KeywordTokenizerFactory 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);
}
use of org.apache.lucene.analysis.core.KeywordTokenizerFactory in project lucene-solr by apache.
the class ResourceLoaderTest method testAwareCompatibility.
public void testAwareCompatibility() throws Exception {
Class<?> clazz = ResourceLoaderAware.class;
// Check ResourceLoaderAware valid objects
assertAwareCompatibility(clazz, new NGramFilterFactory(new HashMap<>()));
assertAwareCompatibility(clazz, new KeywordTokenizerFactory(new HashMap<>()));
// Make sure it throws an error for invalid objects
Object[] invalid = new Object[] { // new NGramTokenFilter( null ),
"hello", new Float(12.3f), new LukeRequestHandler(), new JSONResponseWriter() };
for (Object obj : invalid) {
try {
assertAwareCompatibility(clazz, obj);
Assert.fail("Should be invalid class: " + obj + " FOR " + clazz);
}// OK
catch (SolrException ex) {
}
}
clazz = SolrCoreAware.class;
// Check ResourceLoaderAware valid objects
assertAwareCompatibility(clazz, new LukeRequestHandler());
assertAwareCompatibility(clazz, new FacetComponent());
assertAwareCompatibility(clazz, new JSONResponseWriter());
// Make sure it throws an error for invalid objects
invalid = new Object[] { new NGramFilterFactory(new HashMap<>()), "hello", new Float(12.3f), new KeywordTokenizerFactory(new HashMap<>()) };
for (Object obj : invalid) {
try {
assertAwareCompatibility(clazz, obj);
Assert.fail("Should be invalid class: " + obj + " FOR " + clazz);
}// OK
catch (SolrException ex) {
}
}
}
use of org.apache.lucene.analysis.core.KeywordTokenizerFactory 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);
}
Aggregations