开发者

Zend Lucene - cannot search numbers

开发者 https://www.devze.com 2022-12-30 05:04 出处:网络
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

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_Analy开发者_如何学编程zer_Common_TextNum_CaseInsensitive());

any thougts?


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_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive());


Did you use that command before or after calling Zend_Search_Lucene::open()?

Calling it beforehand definitely works.


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))

0

精彩评论

暂无评论...
验证码 换一张
取 消