lucene 中 BooleanClause.Occur.Must 和 BooleanClause.Occur.SHOULD 之间的区别 [英] Difference between BooleanClause.Occur.Must and BooleanClause.Occur.SHOULD in lucene
问题描述
谁能举例说明 BooleanQuery 中 lucene 中 BooleanClause.Occur.Must 和 BooleanClause.Occur.SHOULD 的区别?
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 之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!