嵌套的BooleanQuery? [英] Nested BooleanQuery?

查看:90
本文介绍了嵌套的BooleanQuery?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用BooleanQuery组合多个查询.我发现如果将BooleanQuery添加到BooleanQuery中,则不会返回任何结果.添加的BooleanQuery是一个MUST_NOT,如-city_id:100.

I'm using a BooleanQuery to combine several queries. I find that if I add a BooleanQuery to the BooleanQuery, then no result is returned. The added BooleanQuery is a MUST_NOT one, like -city_id:100.

但是正如lucene的规范所说,BooleanQuery可以嵌套,我认为这意味着可以添加这样的BooleanQuery.现在,我必须从BooleanQuery中获取所有要添加的子句,然后将它们逐个添加到容器BooleanQuery中.

But as lucene's spec says, BooleanQuery could be nested, which I think means it's okay to add such BooleanQuery. Now I have to get all clauses from the BooleanQuery to be added, and then add them to the container BooleanQuery one by one.

我有点困惑.有人可以帮忙吗?非常感谢你!

I'm a bit confused. Anybody could help? Thank you very much!

推荐答案

Lucene不支持一元NOT运算符.但是您可以通过与

Lucene does not support unary NOT operator. But you can get results for such query by ANDing it with MatchAllDocsQuery.

这篇关于嵌套的BooleanQuery?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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