Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xunsearch是否支持同一个字段的两次range搜索 #28

Closed
shoutrain opened this issue Jan 13, 2016 · 8 comments
Closed

xunsearch是否支持同一个字段的两次range搜索 #28

shoutrain opened this issue Jan 13, 2016 · 8 comments

Comments

@shoutrain
Copy link

xunsearch是否支持同一个字段的两次range搜索?比如,有个字段是age,我能否这样搜索:10 < age < 15 and 20 < age < 25?

@hightman
Copy link
Owner

可以吧。

Best Regards

hightman/海鳗


微信/微博:hightman
Github:https://github.com/hightman

在 2016年1月13日,下午3:46,Rafael Gu notifications@github.com 写道:

xunsearch是否支持同一个字段的两次range搜索?比如,有个字段是age,我能否这样搜索:10 < age < 15 and 20 < age < 25?


Reply to this email directly or view it on GitHub #28.

@shoutrain
Copy link
Author

@hightman 问过国外的论坛,在Xapian上是可以直接支持age:15..25 OR age:35..45这种搜索语句的。但是我用XunSearch不可以,我是在增加一些索引后,在demo上测试的,如下:

util/Quest.php demo "chrono:1314336167..1314337169 OR chrono:1314341167..1314343169"

上面这条语句,OR前面或后面都可以单独查询出结果,但是一起就没有结果了。

@hightman
Copy link
Owner

你可以用 XSSearch:addRange 啊,放在 query 里解析似乎 不会成功。

Best Regards

hightman/海鳗


微信/微博:hightman
Github:https://github.com/hightman

在 2016年1月19日,上午10:25,Rafael Gu notifications@github.com 写道:

@hightman https://github.com/hightman 问过国外的论坛,在Xapian上是可以直接支持age:15..25 OR age:35..45这种搜索语句的。但是我用XunSearch不可以,我是在增加一些索引后,在demo上测试的,如下:
util/Quest.php demo "chrono:1314336167..1314337169 OR chrono:1314341167..1314343169"
上面这条语句,OR前面或后面都可以单独查询出结果,但是一起就没有结果了。


Reply to this email directly or view it on GitHub #28 (comment).

@shoutrain
Copy link
Author

@hightman 但是addRange两次,是AND关系,或者有地方设置默认的关系?

require '/usr/local/xunsearch/sdk/php/lib/XS.php';
$xs = new XS('demo');
$search = $xs->search;

$search->setQuery('');
$search->addRange('chrono', 1314336167, 1314337169);
$search->addRange('chrono', 1314341167, 1314343169);
$docs = $search->search();

foreach($docs as $doc) {
    echo $doc->pid . ' ';
    echo $doc->subject . ' ';
    echo $doc->message . ' ';
    echo $doc->chrono . '<br/>';
}

@hightman
Copy link
Owner

确实不行,add range 固定为 op_filter 关系 (即AND)
parse_query 印象中是不支持2次的。

Best Regards

hightman/海鳗


微信/微博:hightman
Github:https://github.com/hightman

在 2016年1月19日,下午2:39,Rafael Gu notifications@github.com 写道:

@hightman https://github.com/hightman 虽然没试过,但是addRange两次,是OR关系还是AND关系呢?想到这个就觉得addRange是不是有问题?或者有地方设置默认的关系?


Reply to this email directly or view it on GitHub #28 (comment).

@shoutrain
Copy link
Author

@hightman 好的,谢谢,那我研究一下Xapian和其PHP接口,您觉得有可能实现我想要的功能吗?如果有可能我们可以放到XunSearch中。

@hightman
Copy link
Owner

自己构建 Xapian::Query 肯定可以啊,只是xs这要相互通讯有点麻烦。xs每次add query都是在基础query上,而不能分离它们。

比如:当前是 q1,此时添加为 q1 and q2,再以or 添加 q3 就变成 (q1 AND q2) OR q3 而无法做到 q1 AND (q2 OR q3)

Best Regards

hightman/海鳗


微信/微博:hightman
Github:https://github.com/hightman

在 2016年1月19日,下午4:55,Rafael Gu notifications@github.com 写道:

@hightman https://github.com/hightman 好的,谢谢,那我研究一下Xapian和其PHP接口,您觉得有可能实现我想要的功能吗?如果有可能我们可以放到XunSearch中。


Reply to this email directly or view it on GitHub #28 (comment).

@shoutrain
Copy link
Author

@hightman 好的,我来尝试一下,我给您的邮箱发了我的微信,希望微信能让沟通效率高一点。我现在正在CentOS 7上装Xapian.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants