lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erick Erickson <erickerick...@gmail.com>
Subject Re: Error instantiating a Custom Filter in Solr
Date Thu, 07 Nov 2013 22:55:09 GMT
Well, the example you linked to is based on 3.6, and things have
changed assuming you're using 4.0.

It's probably that your ContentFilter isn't implementing what it needs to
or it's not subclassing from the correct class for 4.0.

Maybe take a look at something simple like LowerCaseFilterFactory
and use that as a model, although you probably don't need to implement
the MultiTermAware bit.

FWIW,
Erick


On Thu, Nov 7, 2013 at 1:31 PM, Dileepa Jayakody
<dileepajayakody@gmail.com>wrote:

> Hi All,
>
> I'm  a novice in Solr and I'm continuously bumping into problems with my
> custom filter I'm trying to use for analyzing a fieldType during indexing
> as below;
>
> <fieldType name="stanbolRequestType" class="solr.TextField">
>   <analyzer type="index">
>     <tokenizer class="solr.KeywordTokenizerFactory"/>
>     <filter class= "com.solr.test.analyzer.ContentFilterFactory"/>
>   </analyzer>
> </fieldType>
>
> Below is my custom FilterFactory class;
>
> *public class ContentFilterFactory extends TokenFilterFactory {*
>
> * public ContentFilterFactory() {*
> * super();*
> * }*
>
> * @Override*
> * public TokenStream create(TokenStream input) {*
> * return new ContentFilter(input);*
> * }*
> *}*
>
> I'm getting below error stack trace [1] caused by a NoSuchMethodException
> when starting the server.
> Solr complains that it cannot init the Plugin (my custom filter)  as the
> FilterFactory class doesn't have a init method; But in the example [2] I
> was following didn't have any notion of a init method in the FilterFactory
> class, nor I was required to override an init method when extending
> TokenFilterFactory class.
>
> Can someone please help me resolve this error and get my custom filter
> working?
>
> Thanks,
> Dileepa
>
> [1]
> Caused by: org.apache.solr.common.SolrException: Plugin init failure for
> [schema.xml] fieldType "stanbolRequestType": Plugin init failure for
> [schema.xml] analyzer/filter: Error instantiating class:
> 'com.solr.test.analyzer.ContentFilterFactory'
> at
>
> org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:177)
> at org.apache.solr.schema.IndexSchema.readSchema(IndexSchema.java:468)
> ... 13 more
> Caused by: org.apache.solr.common.SolrException: Plugin init failure for
> [schema.xml] analyzer/filter: Error instantiating class:
> 'com.solr.test.analyzer.ContentFilterFactory'
> at
>
> org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:177)
> at
>
> org.apache.solr.schema.FieldTypePluginLoader.readAnalyzer(FieldTypePluginLoader.java:400)
> at
>
> org.apache.solr.schema.FieldTypePluginLoader.create(FieldTypePluginLoader.java:95)
> at
>
> org.apache.solr.schema.FieldTypePluginLoader.create(FieldTypePluginLoader.java:43)
> at
>
> org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:151)
> ... 14 more
> Caused by: org.apache.solr.common.SolrException: Error instantiating class:
> 'com.solr.test.analyzer.ContentFilterFactory'
> at
>
> org.apache.solr.core.SolrResourceLoader.newInstance(SolrResourceLoader.java:556)
> at
>
> org.apache.solr.schema.FieldTypePluginLoader$3.create(FieldTypePluginLoader.java:382)
> at
>
> org.apache.solr.schema.FieldTypePluginLoader$3.create(FieldTypePluginLoader.java:376)
> at
>
> org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:151)
> ... 18 more
> Caused by: java.lang.NoSuchMethodException:
> com.solr.test.analyzer.ContentFilterFactory.<init>(java.util.Map)
> at java.lang.Class.getConstructor0(Class.java:2810)
> at java.lang.Class.getConstructor(Class.java:1718)
> at
>
> org.apache.solr.core.SolrResourceLoader.newInstance(SolrResourceLoader.java:552)
> ... 21 more
>
> [2] http://solr.pl/en/2012/05/14/developing-your-own-solr-filter/
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message