forked from qdrant/qdrant
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix condition check for values_count (qdrant#1502)
- Loading branch information
Showing
2 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
openapi/tests/openapi_integration/test_filter_values_count.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import random | ||
|
||
import pytest | ||
|
||
from .helpers.helpers import request_with_validation | ||
from .helpers.collection_setup import basic_collection_setup, drop_collection | ||
|
||
collection_name = 'test_collection_filter_values_count' | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def setup(): | ||
basic_collection_setup(collection_name=collection_name) | ||
yield | ||
drop_collection(collection_name=collection_name) | ||
|
||
|
||
def test_filter_values_count(): | ||
response = request_with_validation( | ||
api='/collections/{collection_name}/points/search', | ||
method="POST", | ||
path_params={'collection_name': collection_name}, | ||
body={ | ||
"vector": [0.2, 0.1, 0.9, 0.7], | ||
"limit": 3, | ||
"filter": { | ||
"must": [ | ||
{ | ||
"key": "city", | ||
"values_count": { | ||
"gt": 2 | ||
} | ||
} | ||
] | ||
} | ||
} | ||
) | ||
assert response.ok | ||
|
||
json = response.json() | ||
assert len(json['result']) == 0 | ||
|
||
response = request_with_validation( | ||
api='/collections/{collection_name}/points/search', | ||
method="POST", | ||
path_params={'collection_name': collection_name}, | ||
body={ | ||
"vector": [0.2, 0.1, 0.9, 0.7], | ||
"limit": 3, | ||
"filter": { | ||
"must": [ | ||
{ | ||
"key": "city", | ||
"values_count": { | ||
"gte": 2 | ||
} | ||
} | ||
] | ||
} | ||
} | ||
) | ||
assert response.ok | ||
|
||
json = response.json() | ||
assert len(json['result']) == 3 | ||
|
||
ids = [x['id'] for x in json['result']] | ||
assert 2 in ids | ||
assert 3 in ids | ||
assert 4 in ids | ||
|
||
response = request_with_validation( | ||
api='/collections/{collection_name}/points/search', | ||
method="POST", | ||
path_params={'collection_name': collection_name}, | ||
body={ | ||
"vector": [0.2, 0.1, 0.9, 0.7], | ||
"limit": 3, | ||
"filter": { | ||
"must": [ | ||
{ | ||
"key": "city", | ||
"values_count": { | ||
"lt": 2 | ||
} | ||
} | ||
] | ||
} | ||
} | ||
) | ||
assert response.ok | ||
|
||
json = response.json() | ||
assert len(json['result']) == 1 | ||
assert json['result'][0]['id'] == 1 |