Skip to content

Commit

Permalink
HSEARCH-4619 Don't match anything in a boolean predicate without any …
Browse files Browse the repository at this point in the history
…clause
  • Loading branch information
yrodiere committed Jun 27, 2022
1 parent d6c8d23 commit 3e3c147
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Expand Up @@ -210,6 +210,11 @@ private void addMinimumShouldMatchConstraint(int ignoreConstraintCeiling,

@Override
public SearchPredicate build() {
if ( mustClauses == null && shouldClauses == null && mustNotClauses == null && filterClauses == null ) {
// HSEARCH-4619: a boolean predicate without any clause must not match anything.
return new ElasticsearchMatchNonePredicate( this );
}

// Forcing to Lucene's defaults. See HSEARCH-3534
if ( minimumShouldMatchConstraints == null && hasAtLeastOneMustOrFilterPredicate() ) {
minimumShouldMatchNumber( 0, 0 );
Expand Down
Expand Up @@ -20,7 +20,7 @@ class ElasticsearchMatchNonePredicate extends AbstractElasticsearchPredicate {
private static final JsonObjectAccessor MATCH_NONE_ACCESSOR = JsonAccessor.root().property( "match_none" )
.asObject();

private ElasticsearchMatchNonePredicate(Builder builder) {
ElasticsearchMatchNonePredicate(AbstractBuilder builder) {
super( builder );
}

Expand Down

0 comments on commit 3e3c147

Please sign in to comment.