Zend Lucene - 无法搜索数字
使用 Zend Lucene 我无法在描述字段中搜索数字
添加如下:
$doc->addField(Zend_Search_Lucene_Field::Text('description', $current_item['item_short_description'], 'utf-8'));
谷歌搜索显示应用以下代码应该可以解决问题,但它没有..:
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive());
有什么想法吗?
Using Zend Lucene I cannot search numbers in description fields
Added it like this:
$doc->addField(Zend_Search_Lucene_Field::Text('description', $current_item['item_short_description'], 'utf-8'));
Googling for this showed that applying following code should solve the problem, but it did not..:
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive());
any thougts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您必须设置默认分析器两次:在索引过程和搜索过程中。
使用上面的代码行:
You have to set the default analyzer twice: On the indexing process as well as on the searching process.
Use the code line from above:
您在调用 Zend_Search_Lucene::open() 之前还是之后使用了该命令?
事先调用它肯定有效。
Did you use that command before or after calling Zend_Search_Lucene::open()?
Calling it beforehand definitely works.
我不确定“zend”,但是为了在 lucene 中处理数字,您需要使用以下技术:
要将 int 放置到文档中,请使用以下内容:
document.Add(new Field(FIELD_SPEC, NumberTools.LongToString(YOUR_INT), Field.Store.YES, Field.Index.UN_TOKENIZED));
要查找值,请使用 Term: Term(FIELD_SPEC, NumberTools.LongToString(YOUR_INT))
I'm not sure about 'zend', but for deal with number in lucene, you need use following technique:
To place int to document use following:
document.Add(new Field(FIELD_SPEC, NumberTools.LongToString(YOUR_INT), Field.Store.YES, Field.Index.UN_TOKENIZED));
To locate value use Term: Term(FIELD_SPEC, NumberTools.LongToString(YOUR_INT))