4

The Solr documentation for creating your own token and character filters says the following.

http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters#Specifying_an_Analyzer_in_the_schema

If you want to use custom CharFilters, Tokenizers or TokenFilters, you'll need to write a very simple factory that subclasses BaseTokenizerFactory or BaseTokenFilterFactory, something like this...

public class MyCustomFilterFactory extends BaseTokenFilterFactory {
  public TokenStream create(TokenStream input) {
    return new MyCustomFilter(input);
  }
}

I cannot find the BaseTokenFilterFactory anywhere in the source code for Solr 4.

Here is the org.apache.solr.analysis package from Solr 3.6.1

http://svn.apache.org/viewvc/lucene/dev/tags/lucene_solr_3_6_1/solr/core/src/java/org/apache/solr/analysis/

And here is the same package for Solr 4.0.0

http://svn.apache.org/viewvc/lucene/dev/tags/lucene_solr_4_0_0/solr/core/src/java/org/apache/solr/analysis/

The documentation looks like it will work for Solr 3.6, but I need to know how to create custom filters using 4.0.

1 Answer 1

7

With solr 4.0 the BaseTokenFilterFactory is now org.apache.lucene.analysis.util.TokenFilterFactory, so you can check on this.

3
  • 2
    Also, it is in the analyzers-common JAR. Not entirely obvious.
    – haydenmuhl
    Nov 1, 2012 at 17:45
  • can someone please give a pointer to a jar file which has TokenFilterFactory? Nov 7, 2013 at 7:24
  • What about solr 5.4, I need to make my own filter Feb 5, 2018 at 10:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.