I'm trying to write and use a custom filter for Solr. I've got a filter
factory in myorg/solr/analysis/TestThingFilterFactory.java:

    package myorg.solr.analysis;

    import org.apache.lucene.analysis.TokenStream;
    import org.apache.solr.analysis.BaseTokenFilterFactory;
    import myorg.solr.analysis.TestThingFilter;

    public class TestThingFilterFactory extends BaseTokenFilterFactory {
      public TestThingFilter create(TokenStream input) {
        return new TestThingFilter(input);
      }
    }

and a filter in myorg/solr/analysis/TestThingFilter.java:

    package myorg.solr.analysis;

    import java.io.IOException;
    import org.apache.lucene.analysis.Token;
    import org.apache.lucene.analysis.TokenFilter;
    import org.apache.lucene.analysis.TokenStream;
    import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;

    public class TestThingFilter extends TokenFilter {
      public TestThingFilter(TokenStream input) {
        super(input);
      }

      public boolean incrementToken() throws IOException {
        // ...
      }
    }

I (seemingly successfully) compiled these files with `javac -classpath
apache-solr-core-3.2.0.jar:lucene-core-3.2.0.jar
myorg/solr/analysis/*.java`. I then made a `.jar` file from the .class files
and put the .jar file in the solr/lib/ directory. I modified schema.xml to
include the new filter:

    <fieldType name="text" class="solr.TextField" omitNorms="false">
      <analyzer>
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.ASCIIFoldingFilterFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="myorg.solr.analysis.TestThingFilterFactory"/>
      </analyzer>
    </fieldType>

Restarting Solr and trying to reindex produces this error in the logs:

    SEVERE: java.lang.NoClassDefFoundError:
org/apache/solr/analysis/BaseTokenFilterFactory
    ...
    Caused by: java.lang.ClassNotFoundException:
org.apache.solr.analysis.BaseTokenFilterFactory
    ...

Am I compiling wrong? Perhaps my imports are listed incorrectly?

Cheers,
Mike S Craig
(908) 328 8030

Reply via email to