Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REST] alias with_vector <-> with_vectors #1697

Merged
merged 1 commit into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/collection/src/operations/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ pub struct ScrollRequest {
/// Select which payload to return with the response. Default: All
pub with_payload: Option<WithPayloadInterface>,
/// Whether to return the point vector with the result?
#[serde(default)]
#[serde(default, alias = "with_vectors")]
pub with_vector: WithVector,
}

Expand Down Expand Up @@ -231,7 +231,7 @@ pub struct SearchRequest {
/// Select which payload to return with the response. Default: None
pub with_payload: Option<WithPayloadInterface>,
/// Whether to return the point vector with the result?
#[serde(default)]
#[serde(default, alias = "with_vectors")]
pub with_vector: Option<WithVector>,
/// Define a minimal score threshold for the result.
/// If defined, less similar results will not be returned.
Expand All @@ -254,7 +254,7 @@ pub struct PointRequest {
/// Select which payload to return with the response. Default: All
pub with_payload: Option<WithPayloadInterface>,
/// Whether to return the point vector with the result?
#[serde(default)]
#[serde(default, alias = "with_vectors")]
pub with_vector: WithVector,
}

Expand Down Expand Up @@ -314,7 +314,7 @@ pub struct RecommendRequest {
/// Select which payload to return with the response. Default: None
pub with_payload: Option<WithPayloadInterface>,
/// Whether to return the point vector with the result?
#[serde(default)]
#[serde(default, alias = "with_vectors")]
pub with_vector: Option<WithVector>,
/// Define a minimal score threshold for the result.
/// If defined, less similar results will not be returned.
Expand Down
53 changes: 53 additions & 0 deletions openapi/tests/openapi_integration/test_basic_retrieve_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,56 @@ def query_nested():
)
assert response.ok
assert len(response.json()['result']['points']) == 1


def test_with_vectors_alias_of_with_vector():
database_id = "8594ff5d-265f-adfh-a9f5-b3b4b9665506"
vector = [0.15, 0.31, 0.76, 0.74]

response = request_with_validation(
api='/collections/{collection_name}/points',
method="PUT",
path_params={'collection_name': collection_name},
query_params={'wait': 'true'},
body={
"points": [
{
"id": 8,
"vector": vector,
"payload": {
"database_id": database_id,
}
}
]
}
)
assert response.ok

def scroll_with_vector(keyword):
response = request_with_validation(
api='/collections/{collection_name}/points/scroll',
method='POST',
path_params={'collection_name': collection_name},
body={
keyword: True, # <--- should make no difference
"filter": {
"must": [
{
"key": "database_id",
"match": {
"value": database_id
}
}
]
},
"limit": 1,
}
)

assert response.ok
body = response.json()

assert body["result"]["points"][0]["vector"] == vector

scroll_with_vector("with_vector")
scroll_with_vector("with_vectors")