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

docs: Improved cURL snippets #32

Merged
merged 6 commits into from
Sep 12, 2024
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
144 changes: 137 additions & 7 deletions fern/apis/master/openapi-overrides.yml

Large diffs are not rendered by default.

388 changes: 375 additions & 13 deletions fern/apis/v1.11.x/openapi-overrides.yml

Large diffs are not rendered by default.

49 changes: 49 additions & 0 deletions snippets/curl/batch_update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
curl -X POST \
'http://localhost:6333/collections/collection_name/points/batch' \
--header 'Content-Type: application/json' \
--header 'api-key: <api-key-value>' \
--data-raw '{
"operations": [
{
"upsert": {
"points": [
{
"id": 1,
"vector": [
0.4,
0.3,
0.2,
0.1
]
}
]
}
},
{
"update_vectors": {
"points": [
{
"id": 1,
"vector": [
0.11,
0.22,
0.33,
0.44
]
}
]
}
},
{
"set_payload": {
"payload": {
"test_payload_2": 2,
"test_payload_3": 3
},
"points": [
1
]
}
}
]
}'
11 changes: 11 additions & 0 deletions snippets/curl/clear_payload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
curl -X POST \
'http://localhost:6333/collections/collection_name/points/payload/clear' \
--header 'Content-Type: application/json' \
--header 'api-key: <api-key-value>' \
--data-raw '{
"points": [
0,
3,
100
]
}'
3 changes: 3 additions & 0 deletions snippets/curl/collection_exists.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
curl -X GET \
'http://localhost:6333/collections/collection_name/exists' \
--header 'api-key: <api-key-value>'
27 changes: 27 additions & 0 deletions snippets/curl/count_points.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Count total number of points in a collection
curl -X POST \
'http://localhost:6333/collections/collection_name/points/count' \
--header 'api-key: <api-key-value>' \
--header 'Content-Type: application/json' \
--data-raw '{
"exact": true
}'

# Count points satisfying a filter condition
curl -X POST \
'http://localhost:6333/collections/collection_name/points/count' \
--header 'api-key: <api-key-value>' \
--header 'Content-Type: application/json' \
--data-raw '{
"filter": {
"must": [
{
"key": "color",
"match": {
"value": "red"
}
}
]
},
"exact": true
}'
60 changes: 31 additions & 29 deletions snippets/curl/create_collection.sh
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
# Minimal curl command to create a collection with a vector field
# Create a collection with default dense vector
curl -X PUT \
'http://localhost:6333/collections/collection_name' \
--header 'api-key: <api-key-value>' \
--header 'Content-Type: application/json' \
--data-raw '{
"vectors": {
"size": 384,
"distance": "Cosine"
}
}'

curl -X PUT http://localhost:6333/collections/collection_name \
-H "api-key: <apiKey>" \
-H "Content-Type: application/json" \
-d '{
"vectors": {
"size": 300,
"distance": "Cosine"
}
}'

# Or with a sparse vector field

curl -X PUT http://localhost:6333/collections/collection_name \
-H "api-key: <apiKey>" \
-H "Content-Type: application/json" \
-d '{
"vectors": {
"size": 1536,
"distance": "Cosine"
},
"sparse_vectors": {
"splade-model-name": {
"index": {
"on_disk": true
}
}
}
}'
# Create a collection with named dense and sparse vectors
curl -X PUT \
'http://localhost:6333/collections/collection_name' \
--header 'api-key: <api-key-value>' \
--header 'Content-Type: application/json' \
--data-raw '{
"vectors": {
"dense-vector-name": {
"size": 1536,
"distance": "Cosine"
},
"sparse_vectors": {
"sparse-vector-name": {
"index": {
"on_disk": true
}
}
}
}
}'
8 changes: 8 additions & 0 deletions snippets/curl/create_field_index.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
curl -X PUT \
'http://localhost:6333/collections/collection_name/index' \
--header 'api-key: <api-key-value>' \
--header 'Content-Type: application/json' \
--data-raw '{
"field_name": "field_name",
"field_schema": "keyword"
}'
3 changes: 3 additions & 0 deletions snippets/curl/create_full_snapshot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
curl -X POST \
'http://localhost:6333/snapshots' \
--header 'api-key: <api-key-value>'
7 changes: 7 additions & 0 deletions snippets/curl/create_shard_key.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
curl -X PUT \
'http://localhost:6333/collections/collection_name/shards' \
--header 'api-key: <api-key-value>' \
--header 'Content-Type: application/json' \
--data-raw '{
"shard_key": "{shard_key}"
}'
3 changes: 3 additions & 0 deletions snippets/curl/create_snapshot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
curl -X POST \
'http://localhost:6333/collections/collection_name/snapshots' \
--header 'api-key: <api-key-value>'
3 changes: 3 additions & 0 deletions snippets/curl/delete_collection.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
curl -X DELETE \
'http://localhost:6333/collections/collection_name' \
--header 'api-key: <api-key-value>'
3 changes: 3 additions & 0 deletions snippets/curl/delete_field_index.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
curl -X DELETE \
'http://localhost:6333/collections/collection_name/index/field_name' \
--header 'api-key: <api-key-value>'
3 changes: 3 additions & 0 deletions snippets/curl/delete_full_snapshot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
curl -X DELETE \
'http://localhost:6333/snapshots/snapshot_name' \
--header 'api-key: <api-key-value>'
38 changes: 38 additions & 0 deletions snippets/curl/delete_payload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Delete payload by ID
curl -X POST \
'http://localhost:6333/collections/collection_name/points/payload/delete' \
--header 'api-key: <api-key-value>' \
--header 'Content-Type: application/json' \
--data-raw '{
"keys": [
"color",
"price"
],
"points": [
0,
3,
100
]
}'

# Delete payload by filter
curl -X POST \
'http://localhost:6333/collections/collection_name/points/payload/delete' \
--header 'api-key: <api-key-value>' \
--header 'Content-Type: application/json' \
--data-raw '{
"keys": [
"color",
"price"
],
"filter": {
"must": [
{
"key": "color",
"match": {
"value": "red"
}
}
]
}
}'
30 changes: 30 additions & 0 deletions snippets/curl/delete_points.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Delete points by IDs
curl -X POST \
'http://localhost:6333/collections/collection_name/points/delete' \
--header 'api-key: <api-key-value>' \
--header 'Content-Type: application/json' \
--data-raw '{
"points": [
0,
3,
100
]
}'

# Delete points by filter
curl -X POST \
'http://localhost:6333/collections/collection_name/points/delete' \
--header 'api-key: <api-key-value>' \
--header 'Content-Type: application/json' \
--data-raw '{
"filter": {
"must": [
{
"key": "color",
"match": {
"value": "red"
}
}
]
}
}'
7 changes: 7 additions & 0 deletions snippets/curl/delete_shard_key.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
curl -X POST \
'http://localhost:6333/collections/collection_name/shards/delete' \
--header 'api-key: <api-key-value>' \
--header 'Content-Type: application/json' \
--data-raw '{
"shard_key": "{shard_key}"
}'
3 changes: 3 additions & 0 deletions snippets/curl/delete_snapshot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
curl -X DELETE \
'http://localhost:6333/collections/collection_name/snapshots/snapshot_name' \
--header 'api-key: <api-key-value>'
38 changes: 38 additions & 0 deletions snippets/curl/delete_vectors.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Delete vectors by ID
curl -X POST \
'http://localhost:6333/collections/collection_name/points/vectors/delete' \
--header 'api-key: <api-key-value>' \
--header 'Content-Type: application/json' \
--data-raw '{
"points": [
0,
3,
10
],
"vectors": [
"text",
"image"
]
}'

# Delete vectors by filter
curl -X POST \
'http://localhost:6333/collections/collection_name/points/vectors/delete' \
--header 'api-key: <api-key-value>' \
--header 'Content-Type: application/json' \
--data-raw '{
"filter": {
"must": [
{
"key": "color",
"match": {
"value": "red"
}
}
]
},
"vectors": [
"text",
"image"
]
}'
38 changes: 38 additions & 0 deletions snippets/curl/discover_batch_points.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
curl -X POST \
'http://localhost:6333/collections/collection_name/points/discover/batch' \
--header 'api-key: <api-key-value>' \
--header 'Content-Type: application/json' \
--data-raw '{
"searches": [
{
"target": [
0.2,
0.1,
0.9,
0.7
],
"context": [
{
"positive": "7f6652c4-89bd-40e0-ab1d-510f7fcddd2b",
"negative": "2c2c9f86-0171-4bd2-9ab0-b4754682cddd"
}
],
"limit": 1
},
{
"target": [
0.5,
0.3,
0.2,
0.3
],
"context": [
{
"positive": 342,
"negative": 213
}
],
"limit": 1
}
]
}'
19 changes: 19 additions & 0 deletions snippets/curl/discover_points.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
curl -X POST \
'http://localhost:6333/collections/collection_name/points/discover' \
--header 'api-key: <api-key-value>' \
--header 'Content-Type: application/json' \
--data-raw '{
"target": [
0.2,
0.1,
0.9,
0.7
],
"context": [
{
"positive": "7f6652c4-89bd-40e0-ab1d-510f7fcddd2b",
"negative": "2c2c9f86-0171-4bd2-9ab0-b4754682cddd"
}
],
"limit": 10
}'
3 changes: 3 additions & 0 deletions snippets/curl/get_collection.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
curl -X GET \
'http://localhost:6333/collections/collection_name' \
--header 'api-key: <api-key-value>'
3 changes: 3 additions & 0 deletions snippets/curl/get_collection_aliases.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
curl -X GET \
'http://localhost:6333/collections/collection_name/aliases' \
--header 'api-key: <api-key-value>'
Loading