Zend_Search_Lucene范围查询错误
我已经为每个文档设置了日期字段。 (关键字)
其中存储的值就是这种格式; 20100511
每次尝试执行范围查询时,都会收到以下错误:
date:[10000000 TO 20000000]
至少一个范围查询边界项 必须是非空术语
有人知道吗?
更新
我已经让它以编程方式工作。 这是否意味着解析器有错误?
$from = new Zend_Search_Lucene_Index_Term('10000000', 'dateOfBirthMod');
$to = new Zend_Search_Lucene_Index_Term('20000000', 'dateOfBirthMod');
$query = new Zend_Search_Lucene_Search_Query_Range($from, $to, true);
I have set up each document with a date field. (keyword)
Values stored in it are in this format; 20100511
Each time I try to perform a ranged query, I get the following error:
date:[10000000 TO 20000000]
At least one range query boundary term
must be non-empty term
Anyone got a clue?
Update
I have gotten this to work programmatically.
Does that mean the parser is buggy?
$from = new Zend_Search_Lucene_Index_Term('10000000', 'dateOfBirthMod');
$to = new Zend_Search_Lucene_Index_Term('20000000', 'dateOfBirthMod');
$query = new Zend_Search_Lucene_Search_Query_Range($from, $to, true);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
实际上,这更多的是一个有问题的默认值,而不是一个错误。您可以更改分析器以允许数字。事实上,您甚至可以编写自定义分析器。请参阅 http://framework.zend.com/manual/en /zend.search.lucene.extending.html
允许数字标记化的设置
在 Zf 1.x 和 Zf 2.x 中
Actually, this is more of a questionable default, not a bug. You can change the analyzer to allow numbers. In fact, you can even write a custom analyzer. See http://framework.zend.com/manual/en/zend.search.lucene.extending.html
The setting for allowing numbers to be tokenized is
in Zf 1.x and in Zf 2.x
显然这是查询解析器中的一个错误(顺便说一句,相当旧)。我建议您对该问题添加评论或打开一个新问题以确认该问题在 ZF 的 xx 版本中仍然发生。
Apparently it is a bug in the query parser (quite old btw). I would suggest that you either add a comment to that issue or open a new one to confirm that it is still happening in version x.x of the ZF.
我已经为这个错误做了一个解决方法,该方法源于名为 tokenize() 的方法,该方法不返回任何值,并且可以在 Zend/Search/Lucene/Analysis/Analyzer.php 中找到
您可以尝试将代码替换为如果您使用最新的 ZF 版本 (1.10.7),请执行以下操作。
我不知道它是否适用于旧版本。
I've made a workaround for this bug which stems from the method called tokenize() which does not return any value and which may be found in the Zend/Search/Lucene/Analysis/Analyzer.php
You can try to replace the code with the following one if you use the latest ZF release (1.10.7).
I don't know whether it works in older releases or not.
首先,您必须将默认分析器更改为 TextNum,以在找到
ZF2 之前允许数字:
其次,您的日期字段必须是关键字,而不是文本。
First, you have to change default Analyzer to TextNum to allow number before finding
ZF2:
Second, your date field MUST be a keyword, not text.