From a0335720f78f5b522dc3db00f12c628e9e98274e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Coss=C3=ADo?= Date: Thu, 14 Dec 2023 17:17:34 +0000 Subject: [PATCH] Move the Update Payload section to Payload page --- .../content/documentation/concepts/payload.md | 263 +++++++++++- .../content/documentation/concepts/points.md | 385 +----------------- 2 files changed, 247 insertions(+), 401 deletions(-) diff --git a/qdrant-landing/content/documentation/concepts/payload.md b/qdrant-landing/content/documentation/concepts/payload.md index 42e5a2377..b09334bc8 100644 --- a/qdrant-landing/content/documentation/concepts/payload.md +++ b/qdrant-landing/content/documentation/concepts/payload.md @@ -280,6 +280,8 @@ client ### Set payload +Set only the given payload values on a point. + REST API ([Schema](https://qdrant.github.io/qdrant/redoc/index.html#operation/set_payload)): ```http @@ -323,7 +325,7 @@ use qdrant_client::qdrant::{ use serde_json::json; client - .set_payload( + .set_payload_blocking( "{collection_name}", None, &PointsSelector { @@ -342,32 +344,129 @@ client .await?; ``` -### Delete payload - -This method removes specified payload keys from specified points - -REST API ([Schema](https://qdrant.github.io/qdrant/redoc/index.html#operation/delete_payload)): +You don't need to know the ids of the points you want to modify. The alternative +is to use filters. ```http -POST /collections/{collection_name}/points/payload/delete +POST /collections/{collection_name}/points/payload { - "keys": ["color", "price"], - "points": [0, 3, 100] + "payload": { + "property1": "string", + "property2": "string" + }, + "filter": { + "must": [ + { + "key": "color", + "match": { + "value": "red" + } + } + ] + } } ``` ```python -client.delete_payload( +client.set_payload( collection_name="{collection_name}", - keys=["color", "price"], - points=[0, 3, 100], + payload={ + "property1": "string", + "property2": "string", + }, + points=models.Filter( + must=[ + models.FieldCondition( + key="color", + match=models.MatchValue(value="red"), + ), + ], + ), ) ``` ```typescript -client.deletePayload("{collection_name}", { - keys: ["color", "price"], - points: [0, 3, 100], +client.setPayload("{collection_name}", { + payload: { + property1: "string", + property2: "string", + }, + filter: { + must: [ + { + key: "color", + match: { + value: "red", + }, + }, + ], + }, +}); +``` + +```rust +use qdrant_client::qdrant::{ + points_selector::PointsSelectorOneOf, Condition, Filter, PointsSelector, +}; +use serde_json::json; + +client + .set_payload_blocking( + "{collection_name}", + None, + &PointsSelector { + points_selector_one_of: Some(PointsSelectorOneOf::Filter(Filter::must([ + Condition::matches("color", "red".to_string()), + ]))), + }, + json!({ + "property1": "string", + "property2": "string", + }) + .try_into() + .unwrap(), + None, + ) + .await?; +``` + +### Overwrite payload + +Fully replace any existing payload with the given one. + +REST API ([Schema](https://qdrant.github.io/qdrant/redoc/index.html#operation/overwrite_payload)): + +```http +PUT /collections/{collection_name}/points/payload +{ + "payload": { + "property1": "string", + "property2": "string" + }, + "points": [ + 0, 3, 100 + ] +} +``` + +```python +client.overwrite_payload( + collection_name="{collection_name}", + payload={ + "property1": "string", + "property2": "string", + }, + points=[0, 3, 10], +) +``` + +```typescript +client.overwritePayload("{collection_name}", { + payload: { + property1: "string", + property2: "string", + }, + points: [0, 3, 10], }); ``` @@ -375,22 +474,31 @@ client.deletePayload("{collection_name}", { use qdrant_client::qdrant::{ points_selector::PointsSelectorOneOf, PointsIdsList, PointsSelector, }; +use serde_json::json; client - .delete_payload( + .overwrite_payload_blocking( "{collection_name}", None, &PointsSelector { points_selector_one_of: Some(PointsSelectorOneOf::Points(PointsIdsList { - ids: vec![0.into(), 3.into(), 100.into()], + ids: vec![0.into(), 3.into(), 10.into()], })), }, - vec!["color".to_string(), "price".to_string()], + json!({ + "property1": "string", + "property2": "string", + }) + .try_into() + .unwrap(), None, ) .await?; ``` +Like [set payload](#set-payload), you don't need to know the ids of the points +you want to modify. The alternative is to use filters. + ### Clear payload This method removes all payload keys from specified points @@ -440,6 +548,125 @@ client +### Delete payload keys + +Delete specific payload keys from points. + +REST API ([Schema](https://qdrant.github.io/qdrant/redoc/index.html#operation/delete_payload)): + +```http +POST /collections/{collection_name}/points/payload/delete +{ + "keys": ["color", "price"], + "points": [0, 3, 100] +} +``` + +```python +client.delete_payload( + collection_name="{collection_name}", + keys=["color", "price"], + points=[0, 3, 100], +) +``` + +```typescript +client.deletePayload("{collection_name}", { + keys: ["color", "price"], + points: [0, 3, 100], +}); +``` + +```rust +use qdrant_client::qdrant::{ + points_selector::PointsSelectorOneOf, PointsIdsList, PointsSelector, +}; + +client + .delete_payload_blocking( + "{collection_name}", + None, + &PointsSelector { + points_selector_one_of: Some(PointsSelectorOneOf::Points(PointsIdsList { + ids: vec![0.into(), 3.into(), 100.into()], + })), + }, + vec!["color".to_string(), "price".to_string()], + None, + ) + .await?; +``` + +Alternatively, you can use filters to delete payload keys from the points. + +```http +POST /collections/{collection_name}/points/payload/delete +{ + "keys": ["color", "price"], + "filter": { + "must": [ + { + "key": "color", + "match": { + "value": "red" + } + } + ] + } +} +``` + +```python +client.delete_payload( + collection_name="{collection_name}", + keys=["color", "price"], + points=models.Filter( + must=[ + models.FieldCondition( + key="color", + match=models.MatchValue(value="red"), + ), + ], + ), +) +``` + +```typescript +client.deletePayload("{collection_name}", { + keys: ["color", "price"], + filter: { + must: [ + { + key: "color", + match: { + value: "red", + }, + }, + ], + }, +}); +``` + +```rust +use qdrant_client::qdrant::{ + points_selector::PointsSelectorOneOf, Condition, Filter, PointsSelector, +}; + +client + .delete_payload_blocking( + "{collection_name}", + None, + &PointsSelector { + points_selector_one_of: Some(PointsSelectorOneOf::Filter(Filter::must([ + Condition::matches("color", "red".to_string()), + ]))), + }, + vec!["color".to_string(), "price".to_string()], + None, + ) + .await?; +``` + ## Payload indexing To search more efficiently with filters, Qdrant allows you to create indexes for payload fields by specifying the name and type of field it is intended to be. diff --git a/qdrant-landing/content/documentation/concepts/points.md b/qdrant-landing/content/documentation/concepts/points.md index ef4f2542d..b1de8b1ca 100755 --- a/qdrant-landing/content/documentation/concepts/points.md +++ b/qdrant-landing/content/documentation/concepts/points.md @@ -846,390 +846,9 @@ client To delete entire points, see [deleting points](#delete-points). -### Set payload +### Update payload -Set the given payload values on a point. - -REST API ([Schema](https://qdrant.github.io/qdrant/redoc/index.html#operation/set_payload)): - -```http -POST /collections/{collection_name}/points/payload -{ - "payload": { - "property1": "string", - "property2": "string" - }, - "points": [ - 0, 3, 100 - ] -} -``` - -```python -client.set_payload( - collection_name="{collection_name}", - payload={ - "property1": "string", - "property2": "string", - }, - points=[0, 3, 10], -) -``` - -```typescript -client.setPayload("{collection_name}", { - payload: { - property1: "string", - property2: "string", - }, - points: [0, 3, 10], -}); -``` - -```rust -use qdrant_client::qdrant::{ - points_selector::PointsSelectorOneOf, PointsIdsList, PointsSelector, -}; -use serde_json::json; - -client - .set_payload_blocking( - "{collection_name}", - None, - &PointsSelector { - points_selector_one_of: Some(PointsSelectorOneOf::Points(PointsIdsList { - ids: vec![0.into(), 3.into(), 10.into()], - })), - }, - json!({ - "property1": "string", - "property2": "string", - }) - .try_into() - .unwrap(), - None, - ) - .await?; -``` - -You don't need to know the ids of the points you want to modify. The alternative -is to use filters. - -```http -POST /collections/{collection_name}/points/payload -{ - "payload": { - "property1": "string", - "property2": "string" - }, - "filter": { - "must": [ - { - "key": "color", - "match": { - "value": "red" - } - } - ] - } -} -``` - -```python -client.set_payload( - collection_name="{collection_name}", - payload={ - "property1": "string", - "property2": "string", - }, - points=models.Filter( - must=[ - models.FieldCondition( - key="color", - match=models.MatchValue(value="red"), - ), - ], - ), -) -``` - -```typescript -client.setPayload("{collection_name}", { - payload: { - property1: "string", - property2: "string", - }, - filter: { - must: [ - { - key: "color", - match: { - value: "red", - }, - }, - ], - }, -}); -``` - -```rust -use qdrant_client::qdrant::{ - points_selector::PointsSelectorOneOf, Condition, Filter, PointsSelector, -}; -use serde_json::json; - -client - .set_payload_blocking( - "{collection_name}", - None, - &PointsSelector { - points_selector_one_of: Some(PointsSelectorOneOf::Filter(Filter::must([ - Condition::matches("color", "red".to_string()), - ]))), - }, - json!({ - "property1": "string", - "property2": "string", - }) - .try_into() - .unwrap(), - None, - ) - .await?; -``` - -### Overwrite payload - -Fully replace any existing payload with the given one. - -REST API ([Schema](https://qdrant.github.io/qdrant/redoc/index.html#operation/overwrite_payload)): - -```http -PUT /collections/{collection_name}/points/payload -{ - "payload": { - "property1": "string", - "property2": "string" - }, - "points": [ - 0, 3, 100 - ] -} -``` - -```python -client.overwrite_payload( - collection_name="{collection_name}", - payload={ - "property1": "string", - "property2": "string", - }, - points=[0, 3, 10], -) -``` - -```typescript -client.overwritePayload("{collection_name}", { - payload: { - property1: "string", - property2: "string", - }, - points: [0, 3, 10], -}); -``` - -```rust -use qdrant_client::qdrant::{ - points_selector::PointsSelectorOneOf, PointsIdsList, PointsSelector, -}; -use serde_json::json; - -client - .overwrite_payload_blocking( - "{collection_name}", - None, - &PointsSelector { - points_selector_one_of: Some(PointsSelectorOneOf::Points(PointsIdsList { - ids: vec![0.into(), 3.into(), 10.into()], - })), - }, - json!({ - "property1": "string", - "property2": "string", - }) - .try_into() - .unwrap(), - None, - ) - .await?; -``` - -Like [set payload](#set-payload), you don't need to know the ids of the points -you want to modify. The alternative is to use filters. - -### Delete payload keys - -REST API ([Schema](https://qdrant.github.io/qdrant/redoc/index.html#operation/delete_payload)): - -```http -POST /collections/{collection_name}/points/payload/delete -{ - "keys": ["color", "price"], - "points": [0, 3, 100] -} -``` - -```python -client.delete_payload( - collection_name="{collection_name}", - keys=["color", "price"], - points=[0, 3, 100], -) -``` - -```typescript -client.deletePayload("{collection_name}", { - keys: ["color", "price"], - points: [0, 3, 100], -}); -``` - -```rust -use qdrant_client::qdrant::{ - points_selector::PointsSelectorOneOf, PointsIdsList, PointsSelector, -}; - -client - .delete_payload_blocking( - "{collection_name}", - None, - &PointsSelector { - points_selector_one_of: Some(PointsSelectorOneOf::Points(PointsIdsList { - ids: vec![0.into(), 3.into(), 100.into()], - })), - }, - vec!["color".to_string(), "price".to_string()], - None, - ) - .await?; -``` - -Alternatively, you can use filters to delete payload keys from the points. - -```http -POST /collections/{collection_name}/points/payload/delete -{ - "keys": ["color", "price"], - "filter": { - "must": [ - { - "key": "color", - "match": { - "value": "red" - } - } - ] - } -} -``` - -```python -client.delete_payload( - collection_name="{collection_name}", - keys=["color", "price"], - points=models.Filter( - must=[ - models.FieldCondition( - key="color", - match=models.MatchValue(value="red"), - ), - ], - ), -) -``` - -```typescript -client.deletePayload("{collection_name}", { - keys: ["color", "price"], - filter: { - must: [ - { - key: "color", - match: { - value: "red", - }, - }, - ], - }, -}); -``` - -```rust -use qdrant_client::qdrant::{ - points_selector::PointsSelectorOneOf, Condition, Filter, PointsSelector, -}; - -client - .delete_payload_blocking( - "{collection_name}", - None, - &PointsSelector { - points_selector_one_of: Some(PointsSelectorOneOf::Filter(Filter::must([ - Condition::matches("color", "red".to_string()), - ]))), - }, - vec!["color".to_string(), "price".to_string()], - None, - ) - .await?; -``` - -### Clear payload - -This method removes all payload keys from specified points - -REST API ([Schema](https://qdrant.github.io/qdrant/redoc/index.html#operation/clear_payload)): - -```http -POST /collections/{collection_name}/points/payload/clear -{ - "points": [0, 3, 100] -} -``` - -```python -client.clear_payload( - collection_name="{collection_name}", - points_selector=models.PointIdsList( - points=[0, 3, 100], - ), -) -``` - -```typescript -client.clearPayload("{collection_name}", { - points: [0, 3, 100], -}); -``` - -```rust -use qdrant_client::qdrant::{ - points_selector::PointsSelectorOneOf, PointsIdsList, PointsSelector, -}; - -client - .clear_payload_blocking( - "{collection_name}", - None, - Some(PointsSelector { - points_selector_one_of: Some(PointsSelectorOneOf::Points(PointsIdsList { - ids: vec![0.into(), 3.into(), 100.into()], - })), - }), - None, - ) - .await?; -``` +Learn how to modify the payload of a point in the [Payload](../payload/#update-payload) section. ## Delete points