Zend lucene-在范围内搜索 [英] Zend lucene - search within range

查看:92
本文介绍了Zend lucene-在范围内搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码来创建Zend Lucene索引

I have the following code to create the Zend Lucene index

        $doc->addField(Zend_Search_Lucene_Field::UnStored('keywords', $job->getKeywords()));
        $doc->addField(Zend_Search_Lucene_Field::UnStored('title', $job->getTitle()));
        $doc->addField(Zend_Search_Lucene_Field::UnStored('region', $job->getRegion()));
        $doc->addField(Zend_Search_Lucene_Field::keyword('minSalary', $minSalary));
        $doc->addField(Zend_Search_Lucene_Field::keyword('maxSalary', $maxSalary));
        $doc->addField(Zend_Search_Lucene_Field::UnStored('type', $job->getType()));

我的搜索查询是

$query = 'minSalary:[0 TO 20000]';

在这里,我试图获取所有minSalary等于或小于20000的工作.但是我得到的结果是具有遵循minSalary值的工作

Here I am trying to get all jobs whose minSalary is equal or less than 20000. But the result I get has jobs with following minSalary values

110000
100000
20000
10000

有人可以提出建议吗?

谢谢 B

推荐答案

我建议使用字符串而不是数字值.在索引过程中,将所有数字值(例如1000)转换为具有相同长度(例如0001000)的字符串.因此,如果要搜索从0到20000的minSalary,则查询字符串必须如下所示:

I suggest to use strings instead of numeric values. Convert all numeric values (e.g. 1000) in strings with the same length (e.g. 0001000) during the indexing process. So, if you want to search for a minSalary from 0 to 20000, your query string has to look like this:

$query = "minSalary:[0000000 TO 0020000]";

这篇关于Zend lucene-在范围内搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆