Search by number in zend lucene

401 views Asked by At

I read some articles about searching in indexes by numbers, but it does not work for me yet.

more:: i need to search in my documents by number but it does not work.

i create the docuemnt:

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

and i search the index:

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

but it does not work and the result is empty! i have to do that.

i tested this by changing index type to keyword,unstored,text, and unindexed

Here is my 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());

I am using this on searching and indexing. Also I commented other settings, but they also didn't work.

1

There are 1 answers

0
tasmaniski On

Type of id filed should be "Keyword", so:

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

UnIndexed fields are not searchable.

Read section: Understanding Field Types Zend Lucene