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.
[order-by] Fix remote shard calling (qdrant#4054)
* failing test * - better deserialization of ordering value - ensure ordering value crosses a remote shard call - fetch `with_payload` after merging from shards * WIP: Fix inter shard order by tests fix (qdrant#4056) * tests: Adjust assertion to check point.payload.index value * tests: Fix failing test * Revert "tests: Fix failing test" This reverts commit f21fa4a. * fix default `with_payload` value * set with_payload_interface=false * remove the extra `retrieve` call --------- Co-authored-by: tellet-q <166374656+tellet-q@users.noreply.github.com>
- Loading branch information
Showing
4 changed files
with
244 additions
and
12 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
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
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
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,163 @@ | ||
import requests | ||
|
||
from .assertions import assert_http_ok | ||
from .fixtures import create_collection | ||
from .utils import every_test, start_cluster | ||
|
||
COLL_NAME = "test_collection" | ||
|
||
|
||
def test_order_by_from_remote_shard(tmp_path, every_test): | ||
peer_api_uris, peer_dirs, bootstrap_uri = start_cluster(tmp_path, num_peers=2, port_seed=10000) | ||
|
||
uri = peer_api_uris[0] | ||
|
||
create_collection(uri, collection=COLL_NAME, shard_number=2, replication_factor=1) | ||
|
||
requests.put( | ||
f"{uri}/collections/{COLL_NAME}/index", | ||
json={"field_name": "index", "field_schema": "integer"}, | ||
).raise_for_status() | ||
|
||
res = requests.put( | ||
f"{uri}/collections/{COLL_NAME}/points", | ||
params={ | ||
"wait": "true", | ||
}, | ||
json={ | ||
"points": [ | ||
{ | ||
"id": 0, | ||
"payload": { | ||
"index": 0, | ||
"timestamp": "2024-04-12T08:40:06.189301", | ||
"text": "Italy: tomatoes, olive oil, pasta.", | ||
"title": "food", | ||
}, | ||
"vector": {}, | ||
} | ||
] | ||
}, | ||
) | ||
assert_http_ok(res) | ||
|
||
requests.put( | ||
f"{uri}/collections/{COLL_NAME}/points", | ||
params={ | ||
"wait": "true", | ||
}, | ||
json={ | ||
"batch": { | ||
"ids": [11, 12, 13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], | ||
"payloads": [ | ||
{ | ||
"timestamp": "2024-04-12T08:40:20.015587", | ||
"text": "Japan: Polite, punctual, public transport reliance", | ||
"index": 11, | ||
"title": "travel", | ||
}, | ||
{ | ||
"timestamp": "2024-04-12T08:40:20.290047", | ||
"text": "Italy: Relaxed, historical tours, slow-paced", | ||
"index": 12, | ||
"title": "travel", | ||
}, | ||
{ | ||
"timestamp": "2024-04-12T08:40:20.562687", | ||
"text": "USA: Road trips, diverse landscapes.", | ||
"index": 13, | ||
"title": "travel", | ||
}, | ||
{ | ||
"timestamp": "2024-04-12T08:40:09.482208", | ||
"text": "Japan: seafood-centric with artistic presentation.", | ||
"index": 1, | ||
"title": "food", | ||
}, | ||
{ | ||
"timestamp": "2024-04-12T08:40:09.744967", | ||
"text": "Mexico: beans, chili peppers, and meat.", | ||
"index": 2, | ||
"title": "food", | ||
}, | ||
{ | ||
"timestamp": "2024-04-12T08:40:10.020073", | ||
"text": "India: diverse vegetarian and meat dishes.", | ||
"index": 3, | ||
"title": "food", | ||
}, | ||
{ | ||
"timestamp": "2024-04-12T08:40:10.285342", | ||
"text": "France: Gourmet dining, focuses on cheese, wine", | ||
"index": 4, | ||
"title": "food", | ||
}, | ||
{ | ||
"timestamp": "2024-04-12T08:40:10.883714", | ||
"text": "China: diverse cuisines, emphasizes balance, uses rice", | ||
"index": 5, | ||
"title": "food", | ||
}, | ||
{ | ||
"timestamp": "2024-04-12T08:40:13.166867", | ||
"text": "Thailand: five flavors, spicy, sweet, salty, sour.", | ||
"index": 6, | ||
"title": "food", | ||
}, | ||
{ | ||
"timestamp": "2024-04-12T08:40:15.436143", | ||
"text": "USA: Melting pot, diverse, large portions, fast food.", | ||
"index": 7, | ||
"title": "food", | ||
}, | ||
{ | ||
"timestamp": "2024-04-12T08:40:15.697163", | ||
"text": "Brazil: barbecue heavy", | ||
"index": 8, | ||
"title": "food", | ||
}, | ||
{ | ||
"timestamp": "2024-04-12T08:40:15.963504", | ||
"text": "Greece: Olive oil, feta, yogurt, seafood", | ||
"index": 9, | ||
"title": "food", | ||
}, | ||
{ | ||
"timestamp": "2024-04-12T08:40:16.738832", | ||
"text": "Ethiopia: bread with spicy stews and vegetables", | ||
"index": 10, | ||
"title": "food", | ||
}, | ||
], | ||
"vectors": {}, | ||
} | ||
}, | ||
).raise_for_status() | ||
|
||
res = requests.post( | ||
f"{uri}/collections/{COLL_NAME}/points/scroll", json={"limit": 10, "order_by": "index"} | ||
) | ||
|
||
assert_http_ok(res) | ||
|
||
for point in res.json()["result"]["points"]: | ||
assert point["payload"] is not None | ||
|
||
values = [point["payload"]["index"] for point in res.json()["result"]["points"]] | ||
|
||
assert values == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | ||
|
||
# It should also work when with_payload is False | ||
res = requests.post( | ||
f"{uri}/collections/{COLL_NAME}/points/scroll", | ||
json={"limit": 10, "order_by": "index", "with_payload": False}, | ||
) | ||
|
||
assert_http_ok(res) | ||
|
||
ids = [point["id"] for point in res.json()["result"]["points"]] | ||
|
||
assert ids == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | ||
|
||
for point in res.json()["result"]["points"]: | ||
assert point["payload"] is None |