views:

104

answers:

2

I just noticed that the Zend lucene implementation has a default analyzer that can be modified using Zend_Search_Lucene_Analysis_Analyzer::setDefault(), but I couldn't find a way to override that default when performing a query. Do I really need to reset the default analyzer if I'm working on multiple indexes or am I missing a function?

+1  A: 

In the original Java API for Lucene, QueryParser takes an analyzer argument. I'm not sure why they decided to use a global variable in Zend Framework, but apparently setting the analyzer globally is the only way to do it.

Lukáš Lalinský
Thanks, I guess the API is just stupid.
soulmerge
A: 

I use the TextNum analyzer because the default (Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive) doesn't allow searching by integers.

To override the default, I run:

Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum());
Derek Gathright