【问题标题】:Search by number in zend lucene在zend lucene中按数字搜索
【发布时间】:2012-02-26 17:33:42
【问题描述】:

我阅读了一些关于按数字搜索索引的文章,但它对我还不起作用。

更多:: 我需要按编号在我的文档中搜索,但它不起作用。

我创建文档:

$doc1->addField(Zend_Search_Lucene_Field::UnIndexed('id', $id));

然后我搜索索引:

$index->find("id:123");

但它不起作用,结果为空!我必须这样做。

我通过将索引类型更改为关键字、未存储、文本和未索引来测试这一点

这是我的 Bootstrap::

Zend_Search_Lucene_Analysis_Analyzer::setDefault
        (new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8());

Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');

Zend_Search_Lucene_Analysis_Analyzer::setDefault
        (new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive());

Zend_Search_Lucene_Analysis_Analyzer::setDefault
          (new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum());

我在搜索和索引时使用它。我还评论了其他设置,但它们也不起作用。

【问题讨论】:

  • 你能具体说说你的问题吗?

标签: search indexing numbers zend-lucene


【解决方案1】:

id 字段的类型应该是“关键字”,所以:

$doc1->addField(Zend_Search_Lucene_Field::Keyword('id', $id));

未索引的字段不可搜索。

阅读部分:Understanding Field Types Zend Lucene

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多