Skip to content

Commit 115e097

Browse files
committed
PYCBC-1694: Allow setting min=0 in DisjunctionQuery
Motivation ========== The server accepts disjunction queries with min=0. In the case of a standalone DisjunctionQuery, it is equivalent to the default (min=1). When used as part of a BooleanQuery, min=0 means that the disjuncts only affect the scoring. Change ====== Update DisjunctionQuery.min setter to only raise an error if min is negative. Results ======= Relevant FIT test passes (SearchTest.booleanQueryNotMatchMin0) Change-Id: I17b13522ef2ac3b603c5e4f568771161fd0c92a5 Reviewed-on: https://review.couchbase.org/c/couchbase-python-client/+/230750 Tested-by: Build Bot <build@couchbase.com> Reviewed-by: Jared Casey <jared.casey@couchbase.com>
1 parent d8fa031 commit 115e097

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

couchbase/logic/search_queries.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -862,11 +862,11 @@ def min(self) -> int:
862862
return self._json_.get('min', None)
863863

864864
@min.setter
865-
def min(self, value # type: bool
865+
def min(self, value # type: int
866866
) -> None:
867867
value = int(value)
868-
if not value:
869-
raise InvalidArgumentException(message='Must be > 0')
868+
if value < 0:
869+
raise InvalidArgumentException(message='Must be >= 0')
870870
self.set_prop('min', value)
871871

872872
@property

couchbase/tests/search_params_t.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def test_disjunction_query(self, cb_env):
250250
assert encoded_q['query'] == disjuncts
251251

252252
with pytest.raises(InvalidArgumentException):
253-
q.min = 0
253+
q.min = -1
254254

255255
q.min = 2
256256
search_query = search.SearchQueryBuilder.create_search_query_object(

0 commit comments

Comments
 (0)