Details
Description
Suggested release note:
Fixed a regression introduced in version 3.4.5 that caused a Full-Text Search `BooleanQuery` to throw `InvalidArgumentException: Compound query has no child query` unless all 3 of "must", "should", and "mustNot" were specified.
Method com.couchbase.client.java.search.SearchQuery#booleans throws an InvalidArgumentException
com.couchbase.client.core.error.InvalidArgumentException: Compound query has no child query
|
at com.couchbase.client.core.error.InvalidArgumentException.fromMessage(InvalidArgumentException.java:28) |
at com.couchbase.client.core.api.search.queries.CoreDisjunctionQuery.<init>(CoreDisjunctionQuery.java:41) |
at com.couchbase.client.java.search.queries.DisjunctionQuery.toCore(DisjunctionQuery.java:57) |
at com.couchbase.client.java.search.queries.BooleanQuery.toCore(BooleanQuery.java:71) |
at com.couchbase.client.java.AsyncCluster.searchQuery(AsyncCluster.java:423) |
at com.couchbase.client.java.Cluster.searchQuery(Cluster.java:457) |
This issue is caused by the following code block on lines 35-40 in com.couchbase.client.java.search.queries.BooleanQuery
public BooleanQuery() { |
super(); |
this.must = new ConjunctionQuery(); |
this.should = new DisjunctionQuery(); |
this.mustNot = new DisjunctionQuery(); |
}
|
New ConjunctionQuery / DisjunctionQuery classes are instantiated in the above BooleanQuery constructor without a SearchQuery parameter.
This ultimately results in a call to the com.couchbase.client.core.api.search.queries.CoreDisjunctionQuery#CoreDisjunctionQuery constructor in core-io - which is imported transitively at version 2.4.10 - with an empty 'List<CoreSearchQuery> queries' parameter.
Version 2.4.10 of CoreDisjunctionQuery has a guard at line 40 which throws an
InvalidArgumentException when the List<CoreSearchQuery> parameter is empty, as per below code:
public CoreDisjunctionQuery(List<CoreSearchQuery> queries, @Nullable Integer min, @Nullable Double boost) { |
super(queries, boost); |
this.min = min; |
|
if (childQueries.isEmpty()) { |
throw InvalidArgumentException.fromMessage("Compound query has no child query"); |
}
|
if (min != null && childQueries.size() < min) { |
throw InvalidArgumentException.fromMessage("Disjunction query has fewer children than the configured minimum " + min); |
}
|
}
|
Attachments
Issue Links
- relates to
-
SCBC-428 FTS BooleanQuery fails unless all 3 of "must", "should", and "mustNot" are specified
- Open