问题描述
任何人都可以用一个例子解释BooleanClause.Occur.Must和BooleanClause.Occur.SHOULD之间的差异的Lucene BooleanQuery?
Can anyone explain the difference between the BooleanClause.Occur.Must and BooleanClause.Occur.SHOULD in lucene in BooleanQuery with an example?
推荐答案
BooleanClause.Occur.SHOULD
表示子句是可选的,而 BooleanClause .Occur.Must
意味着该条款是强制性的。
BooleanClause.Occur.SHOULD
means that the clause is optional, whereas BooleanClause.Occur.Must
means that the clause is compulsory.
但是,如果一个布尔查询只有可选的条款,至少有一个子句必须出现在结果的文件相匹配。
However, if a boolean query only has optional clauses, at least one clause must match for a document to appear in the results.
有关在什么文件匹配BooleanQuery更好的控制,也有minimumShouldMatch参数,它可以让你告诉Lucene的,至少 minimumShouldMatch
BooleanClause.Occur.SHOULD
条款必须出现在文档匹配结果
For better control over what documents match a BooleanQuery, there is also a minimumShouldMatch parameter which lets you tell Lucene that at least minimumShouldMatch
BooleanClause.Occur.SHOULD
clauses must match for a document to appear in the results.
这篇关于在Lucene的BooleanClause.Occur.Must和BooleanClause.Occur.SHOULD的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!