热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

ZendSearchLucene不区分大小写的搜索不起作用-ZendSearchLucenecaseinsensitivesearchdoesn'twork

IvegotaSearchclass,wichhas我有一个搜索课,有publicfunction__construct($isNewIndexfalse){

I've got a Search class, wich has

我有一个搜索课,有

public function __construct($isNewIndex = false) {
    setlocale(LC_CTYPE, 'ru_RU.UTF-8');

    $analyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive();
    $morphy = new Isi_Search_Lucene_Analysis_TokenFilter_Morphy('ru_RU');
    $analyzer->addFilter($morphy);

    Zend_Search_Lucene_Analysis_Analyzer::setDefault($analyzer);
    Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');

    //if it's true, then it creates new folder to the path in $_indexFieles;
    if ($isNewIndex) {
        $this->_indexes[$this->_key] = Zend_Search_Lucene::create(Yii::getPathOfAlias('application.' . $this->_indexFiles), true);
    } else {
        $this->_indexes[$this->_key] = Zend_Search_Lucene::open(Yii::getPathOfAlias('application.' . $this->_indexFiles));
    }
}

 public function find($query, $eventId)
{
    try 
    {
        Zend_Search_Lucene_Search_QueryParser::setDefaultOperator(Zend_Search_Lucene_Search_QueryParser::B_AND);
        $query = "($query) AND (event_id:$eventId)";
        Zend_Search_Lucene::setResultSetLimit(self::ACCREDITATION_LIMIT);
        return $this->_indexes[$this->_key]->find("{$query}");
    } 
    catch (Zend_Search_Lucene_Search_QueryParserException $e) 
    {
        echo "Query syntax error: " . $e->getMessage() . "\n";
    }
    catch (Exception $e) 
    {
        echo $e->getMessage(). "\n";
    }
}

I've got a record with name Test, when I'm looking for Test it works, but can't find this record with request test Code example:

我有一个名为Test的记录,当我正在寻找Test它可以工作时,但找不到这条记录请求测试代码示例:

$s = new Search();
$s->find('test', 1232);//no results

1 个解决方案

#1


I found a solution, the problem was that I was saving fields (name, etc.) as keyword, I changed it to text, and now it's working perfectly.

我找到了一个解决方案,问题是我将字段(名称等)保存为关键字,我将其更改为文本,现在它正在完美运行。


推荐阅读
author-avatar
现实-不过如此
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有