开发者

Zend Search Lucene numerical range searches

I am having difficulty determining my misunderstanding of how Zend Search Lucene indexes and searches integers in ranges.

In the following example, I would expect the output to be 1, however it is always 2 (both results). Any hints would be much 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]')));


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 that does not work, maybe you should use the Zend_Search_Lucene_Field::Text type.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜