【问题标题】:How to build functionality to search like google using zend_search_lucene?如何使用 zend_search_lucene 构建像 google 一样的搜索功能?
【发布时间】:2012-06-04 10:10:57
【问题描述】:

我正在使用 zend_search_lucene 在文档中搜索关键字。 在其中一份文件中,它有短语This taught me a valuable lesson in time management as I still had to attend lectures and tutorials during the day. I enjoyed improving my telephone manner and learning to deal with different reactions to my requests for donations.

现在,如果搜索“关于时间管理的宝贵课程”,它不会得到任何结果。我正在使用下面的代码来搜索它。

Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive());

$index = new Zend_Search_Lucene('/home/project/mgh/data/search_file/lucene.customer.index');

 Zend_Search_Lucene::getDefaultSearchField('contents');

    $results = $index->find('contents:"valuable lesson on cost management" ');

    $this->count=count($results);

在上面的例子中,只有不匹配是,代替“in”,有“on”,但剩余的单词正在匹配。 如果匹配的单词很少(即使很少的单词不匹配)如何获得结果计数?

感谢您的建议。

参考:http://framework.zend.com/manual/en/zend.search.lucene.query-language.html

【问题讨论】:

    标签: php lucene full-text-search search-engine zend-search-lucene


    【解决方案1】:

    这里的关键可能是停用词。如果您将“in”和“on”定义为停用词(Lucene 将忽略这些词,因为它们太常见了),那么您的查询“时间管理有价值的课程”将匹配文档文本的“时间管理的宝贵课程”部分.

    【讨论】:

    • 感谢您的反馈。在上述情况下,可能是因为停用词。但我仍然想知道如何获得结果计数,即使很少有单词匹配,而不管停用词如何......
    【解决方案2】:

    问题不在于 zend_search_lucene,而在于 Lucene 如何索引您的数据。我建议您阅读 Solr 文档中的 Analyzers, Tokenizers, and Token Filters 以了解其工作原理。如果您发布您的 schema.xml 信息(您定义哪些信息应该被索引以及以哪种方式),这也会有所帮助。

    【讨论】:

    • 嗨,我正在将所有类型的文档转换为文本并将其提供给 Lucene 索引。数据不是来自数据库。所以这里没有使用 YML 文件。你能建议我如何实现这一目标...
    • 看看这篇文章blog.stoeckl.de/post/5240774861/zend-search-lucene-vs-solr可能对你有帮助
    猜你喜欢
    • 2015-10-25
    • 2021-09-22
    • 2013-10-05
    • 2022-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多