Search by Zend Search in Lucene

I'm having difficulty defining my misunderstanding of how Zend Search Lucene indexes and searches for integers in ranges.

In the following example, I expect the result to be 1, however it is always 2 (both results). Any hints would be greatly appreciated.

<?php require_once 'Zend/Loader/Autoloader.php'; $loader = Zend_Loader_Autoloader::getInstance(); $search = Zend_Search_Lucene::create('test.index'); $doc = new Zend_Search_Lucene_Document(); $doc->addField(Zend_Search_Lucene_Field::Text('foo', 'Hello')); $doc->addField(Zend_Search_Lucene_Field::Keyword('bar', 100)); $search->addDocument($doc); $doc = new Zend_Search_Lucene_Document(); $doc->addField(Zend_Search_Lucene_Field::Text('foo', 'Hello')); $doc->addField(Zend_Search_Lucene_Field::Keyword('bar', 200)); $search->addDocument($doc); $search->commit(); var_dump(count($search->find('foo:Hello AND bar:[050 TO 150]'))); 
+4
source share
1 answer

I would try changing the addField commands to:

 $doc->addField(Zend_Search_Lucene_Field::Keyword('bar', '100')); 

That is, use a string instead of an integer. If this does not work, perhaps you should use the type Zend_Search_Lucene_Field::Text .

0
source

All Articles