Spaces:
Build error
Build error
File size: 5,376 Bytes
2fdbd5c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# Quick Start
This example covers the most basic use-case - collection creation and basic vector search.
For additional information please refer to the [API documentation](https://api.qdrant.tech/).
## Docker 🐳
Use latest pre-built image from [DockerHub](https://hub.docker.com/r/qdrant/qdrant)
```bash
docker pull qdrant/qdrant
```
Run it with default configuration:
```bash
docker run -p 6333:6333 qdrant/qdrant
```
Build your own from source
```bash
docker build . --tag=qdrant/qdrant
```
And once you need a fine-grained setup, you can also define a storage path and custom configuration:
```bash
docker run -p 6333:6333 \
-v $(pwd)/path/to/data:/qdrant/storage \
-v $(pwd)/path/to/snapshots:/qdrant/snapshots \
-v $(pwd)/path/to/custom_config.yaml:/qdrant/config/production.yaml \
qdrant/qdrant
```
- `/qdrant/storage` - is the place where Qdrant persists all your data.
Make sure to mount it as a volume, otherwise docker will drop it with the container.
- `/qdrant/snapshots` - is the place where Qdrant stores [snapshots](https://qdrant.tech/documentation/concepts/snapshots/)
- `/qdrant/config/production.yaml` - is the file with engine configuration. You can override any value from the [reference config](https://github.com/qdrant/qdrant/blob/master/config/config.yaml). In a real production environment, you should enable authentication by setting `service.apiKey`.
- For production environments, consider also setting [`--read-only`](https://docs.docker.com/reference/cli/docker/container/run/#read-only) and `--user=1000:2000` to further secure your Qdrant instance. Or use [our Helm chart](https://github.com/qdrant/qdrant-helm) or [Qdrant Cloud](https://qdrant.tech/documentation/cloud/) which sets these by default.
Now Qdrant should be accessible at [localhost:6333](http://localhost:6333/).
## Create collection
First - let's create a collection with dot-production metric.
```bash
curl -X PUT 'http://localhost:6333/collections/test_collection' \
-H 'Content-Type: application/json' \
--data-raw '{
"vectors": {
"size": 4,
"distance": "Dot"
}
}'
```
Expected response:
```json
{
"result": true,
"status": "ok",
"time": 0.031095451
}
```
We can ensure that collection was created:
```bash
curl 'http://localhost:6333/collections/test_collection'
```
Expected response:
```json
{
"result": {
"status": "green",
"vectors_count": 0,
"segments_count": 5,
"disk_data_size": 0,
"ram_data_size": 0,
"config": {
"params": {
"vectors": {
"size": 4,
"distance": "Dot"
}
},
"hnsw_config": {
"m": 16,
"ef_construct": 100,
"full_scan_threshold": 10000
},
"optimizer_config": {
"deleted_threshold": 0.2,
"vacuum_min_vector_number": 1000,
"default_segment_number": 2,
"max_segment_size": null,
"memmap_threshold": null,
"indexing_threshold": 20000,
"flush_interval_sec": 5,
"max_optimization_threads": null
},
"wal_config": {
"wal_capacity_mb": 32,
"wal_segments_ahead": 0
}
}
},
"status": "ok",
"time": 2.1199e-5
}
```
## Add points
Let's now add vectors with some payload:
```bash
curl -L -X PUT 'http://localhost:6333/collections/test_collection/points?wait=true' \
-H 'Content-Type: application/json' \
--data-raw '{
"points": [
{"id": 1, "vector": [0.05, 0.61, 0.76, 0.74], "payload": {"city": "Berlin"}},
{"id": 2, "vector": [0.19, 0.81, 0.75, 0.11], "payload": {"city": ["Berlin", "London"] }},
{"id": 3, "vector": [0.36, 0.55, 0.47, 0.94], "payload": {"city": ["Berlin", "Moscow"] }},
{"id": 4, "vector": [0.18, 0.01, 0.85, 0.80], "payload": {"city": ["London", "Moscow"] }},
{"id": 5, "vector": [0.24, 0.18, 0.22, 0.44], "payload": {"count": [0] }},
{"id": 6, "vector": [0.35, 0.08, 0.11, 0.44]}
]
}'
```
Expected response:
```json
{
"result": {
"operation_id": 0,
"status": "completed"
},
"status": "ok",
"time": 0.000206061
}
```
## Search with filtering
Let's start with a basic request:
```bash
curl -L -X POST 'http://localhost:6333/collections/test_collection/points/search' \
-H 'Content-Type: application/json' \
--data-raw '{
"vector": [0.2,0.1,0.9,0.7],
"top": 3
}'
```
Expected response:
```json
{
"result": [
{ "id": 4, "score": 1.362, "payload": null, "version": 0 },
{ "id": 1, "score": 1.273, "payload": null, "version": 0 },
{ "id": 3, "score": 1.208, "payload": null, "version": 0 }
],
"status": "ok",
"time": 0.000055785
}
```
But result is different if we add a filter:
```bash
curl -L -X POST 'http://localhost:6333/collections/test_collection/points/search' \
-H 'Content-Type: application/json' \
--data-raw '{
"filter": {
"should": [
{
"key": "city",
"match": {
"value": "London"
}
}
]
},
"vector": [0.2, 0.1, 0.9, 0.7],
"top": 3
}'
```
Expected response:
```json
{
"result": [
{ "id": 4, "score": 1.362 },
{ "id": 2, "score": 0.871 }
],
"status": "ok",
"time": 0.000093972
}
```
|