开发者

Why is the analyzer defined globally in Zend.Search.Lucene?

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?


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.


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());
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜