【问题标题】:Zend Search Lucene - How do you make your query case insensitive?Zend Search Lucene - 你如何让你的查询不区分大小写?
【发布时间】:2012-09-21 01:52:23
【问题描述】:

在我看来 Zend Search Lucene 默认是区分大小写的搜索。有没有办法改变这种情况,使所有查询都不区分大小写?

【问题讨论】:

    标签: php zend-framework lucene


    【解决方案1】:

    Zend Search Lucene 应该默认不区分大小写(来自文档):

    您可以指定自己的文本分析器或从一组 预定义分析器:Zend_Search_Lucene_Analysis_Analyzer_Common_TextZend_Search_Lucene_Analysis_Analyzer_Common_Text_CaseInsensitive (默认)。它们都将标记解释为字母序列。 Zend_Search_Lucene_Analysis_Analyzer_Common_Text_CaseInsensitive 将所有标记转换为小写。

    你可能有

    Zend_Search_Lucene_Analysis_Analyzer::setDefault(
        new Zend_Search_Lucene_Analysis_Analyzer_Common_Text()
    );
    

    设置某处,将其切换为区分大小写。您可以尝试查找并删除它,或switch analyzers

    【讨论】:

    • 是的,我认为它默认为不区分大小写,但当我尝试搜索时,它是区分大小写的。将尝试您的解决方案
    • 我 var_dumped 默认分析器,果然,它是 Zend_Search_Lucene_Analysis_Analyzer_Common_Text_CaseInsensitive。但是,搜索仍然区分大小写。以下是我推测可能导致问题的一些事情,(1)索引插入过程(2)索引字段的类型
    • 看来这里可能有一些有用的信息(类似问题)-stackoverflow.com/questions/5512803/…
    • 我使用Zend_Search_Lucene_Analysis_Analyzer::getDefault() 输出了默认分析器,我得到了这个Zend_Search_Lucene_Analysis_Analyzer_Common_Text_CaseInsensitive Object ( [_position:Zend_Search_Lucene_Analysis_Analyzer_Common_Text:private] => [_filters:Zend_Search_Lucene_Analysis_Analyzer_Common:private] => Array ( [0] => Zend_Search_Lucene_Analysis_TokenFilter_LowerCase Object ( ) ) [_input:protected] => [_encoding:protected] => ) 似乎默认为小写
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-30
    • 1970-01-01
    • 2011-09-20
    • 2012-12-10
    相关资源
    最近更新 更多