开发者

Boolean Search In Lucene

I have been trying to run the following boolean query in lucene but it seems to fail. Please help.

(a or b) and c -> works fine

(a AND b) or c -> gives result for a AND b OR c. So a becomes must and b and c becomes should, and the search result is wrong. Where it should work like a, b must be available or c may be available.

Another example:

If you search for "(a AND b)" it will return x results

If you s开发者_StackOverflowearch for "c" it will return y results

If you search for "(a and b) or c" the number of results cannot be less than the larger of x or y. But this is not happening. Please help how should I proceed to implement this?


(a AND b) or c gets converted to (+a +b) c. What you want is this without parentheses: +a +b c.

From a logical perspective, "A and B must occur, C might occur" is equivalent to "A and B must occur." (There is no way to say "might be true" in classical logic.) So you will have difficulty saying (+a +b) c in boolean terms. One way you could do it is "(a AND b AND c) or (a AND b)".

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜