You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Edwards, Joshua" <Jo...@capitalone.com> on 2014/08/13 19:23:22 UTC

Does TokenFilterFactory not pick up new Factories automatically?

Hi -

I'm trying to create a new Filter.  When doing this, I've written the basics of the Filter, Factory, and unit test, and everything seems to be working.  For good measure, I wanted to run the full suite of unit tests.  When I do this, TestAllAnalyzersHaveFactories fails, because it can't find my Factory, though it is present and named the same as my Filter (with Factory appended to the end).

Am I missing something simple here?  Do I need to register my factory in a config file or something?  Looking through the loaders, they seem to just grab everything that is available, so I'd expect my Factory to get picked up.

Thanks,
Josh
________________________________________________________

The information contained in this e-mail is confidential and/or proprietary to Capital One and/or its affiliates. The information transmitted herewith is intended only for use by the individual or entity to which it is addressed.  If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer.

RE: Does TokenFilterFactory not pick up new Factories automatically?

Posted by "Edwards, Joshua" <Jo...@capitalone.com>.
Ah.  That explains it!  Thanks!

Josh

From: Uwe Schindler [mailto:uwe@thetaphi.de]
Sent: Wednesday, August 13, 2014 1:31 PM
To: dev@lucene.apache.org
Subject: RE: Does TokenFilterFactory not pick up new Factories automatically?

You have to list your factory in the META-INF/services/ folder in the corresponding file named by the base class (there is one for filters, tokenizers, and charfilters). Lucene reads *all* the services file in classpath to find the implementation classes. If you publish your own JAR, you have to add the file, too, but just with your implementations.

This is explained in SPI:
http://en.wikipedia.org/wiki/Service_provider_interface
http://docs.oracle.com/javase/7/docs/api/java/util/ServiceLoader.html

Uwe

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de<http://www.thetaphi.de/>
eMail: uwe@thetaphi.de<ma...@thetaphi.de>

From: Edwards, Joshua [mailto:Joshua.Edwards@capitalone.com]
Sent: Wednesday, August 13, 2014 7:23 PM
To: dev@lucene.apache.org<ma...@lucene.apache.org>
Subject: Does TokenFilterFactory not pick up new Factories automatically?

Hi –

I’m trying to create a new Filter.  When doing this, I’ve written the basics of the Filter, Factory, and unit test, and everything seems to be working.  For good measure, I wanted to run the full suite of unit tests.  When I do this, TestAllAnalyzersHaveFactories fails, because it can’t find my Factory, though it is present and named the same as my Filter (with Factory appended to the end).

Am I missing something simple here?  Do I need to register my factory in a config file or something?  Looking through the loaders, they seem to just grab everything that is available, so I’d expect my Factory to get picked up.

Thanks,
Josh

________________________________

The information contained in this e-mail is confidential and/or proprietary to Capital One and/or its affiliates. The information transmitted herewith is intended only for use by the individual or entity to which it is addressed.  If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer.
________________________________________________________

The information contained in this e-mail is confidential and/or proprietary to Capital One and/or its affiliates. The information transmitted herewith is intended only for use by the individual or entity to which it is addressed.  If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer.

RE: Does TokenFilterFactory not pick up new Factories automatically?

Posted by Uwe Schindler <uw...@thetaphi.de>.
You have to list your factory in the META-INF/services/ folder in the corresponding file named by the base class (there is one for filters, tokenizers, and charfilters). Lucene reads *all* the services file in classpath to find the implementation classes. If you publish your own JAR, you have to add the file, too, but just with your implementations. 

 

This is explained in SPI: 

http://en.wikipedia.org/wiki/Service_provider_interface

http://docs.oracle.com/javase/7/docs/api/java/util/ServiceLoader.html

 

Uwe

 

-----

Uwe Schindler

H.-H.-Meier-Allee 63, D-28213 Bremen

 <http://www.thetaphi.de/> http://www.thetaphi.de

eMail: uwe@thetaphi.de

 

From: Edwards, Joshua [mailto:Joshua.Edwards@capitalone.com] 
Sent: Wednesday, August 13, 2014 7:23 PM
To: dev@lucene.apache.org
Subject: Does TokenFilterFactory not pick up new Factories automatically?

 

Hi –

 

I’m trying to create a new Filter.  When doing this, I’ve written the basics of the Filter, Factory, and unit test, and everything seems to be working.  For good measure, I wanted to run the full suite of unit tests.  When I do this, TestAllAnalyzersHaveFactories fails, because it can’t find my Factory, though it is present and named the same as my Filter (with Factory appended to the end).  

 

Am I missing something simple here?  Do I need to register my factory in a config file or something?  Looking through the loaders, they seem to just grab everything that is available, so I’d expect my Factory to get picked up.

 

Thanks,

Josh

 

  _____  

The information contained in this e-mail is confidential and/or proprietary to Capital One and/or its affiliates. The information transmitted herewith is intended only for use by the individual or entity to which it is addressed.  If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer.