mirror of
https://github.com/qdrant/landing_page.git
synced 2026-09-27 15:08:30 +02:00
doc v0.7.x (#30)
* doc v0.7.x * docs auto-sync Co-authored-by: qdrant <qdrant@users.noreply.github.com>
This commit is contained in:
co-authored by
qdrant
parent
85a00a667f
commit
eff6883cea
@@ -24,7 +24,7 @@ These settings can be changed at any time by a corresponding request.
|
||||
|
||||
With REST API
|
||||
|
||||
``` http
|
||||
```
|
||||
PUT /collections/example_collection
|
||||
|
||||
{
|
||||
@@ -34,21 +34,6 @@ PUT /collections/example_collection
|
||||
}
|
||||
```
|
||||
|
||||
``` python
|
||||
from qdrant_client import QdrantClient
|
||||
from qdrant_openapi_client.models.models import CreateCollection, Distance
|
||||
|
||||
client = QdrantClient(host="localhost", port=6333)
|
||||
|
||||
client.http.collections_api.create_collection(
|
||||
name="example_collection",
|
||||
create_collection=CreateCollection(
|
||||
distance=Distance.COSINE,
|
||||
vector_size=300,
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
In addition to the required options, you can also specify custom values for the following collection options:
|
||||
|
||||
- `hnsw_config`
|
||||
@@ -121,7 +106,7 @@ All queries to the collection can also be done identically, using an alias inste
|
||||
Thus, it is possible to build a second collection in the background and then switch alias from the old to the new collection.
|
||||
Since all changes of aliases happen atomically, no concurrent requests will be affected during the switch.
|
||||
|
||||
### Create alias
|
||||
### Crate alias
|
||||
|
||||
```
|
||||
POST /collections/aliases
|
||||
@@ -193,4 +178,4 @@ POST /collections/aliases
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
```
|
||||
@@ -5,16 +5,16 @@ weight: 50
|
||||
|
||||
# Distributed Deployment
|
||||
|
||||
ToDo
|
||||
Currently work-in-progress, see [Roadmap](https://github.com/qdrant/qdrant/blob/master/docs/roadmap/README.md)
|
||||
|
||||
## Replication
|
||||
|
||||
ToDo
|
||||
Currently work-in-progress, see [Roadmap](https://github.com/qdrant/qdrant/blob/master/docs/roadmap/README.md)
|
||||
|
||||
## Sharding
|
||||
|
||||
ToDo
|
||||
Currently work-in-progress, see [Roadmap](https://github.com/qdrant/qdrant/blob/master/docs/roadmap/README.md)
|
||||
|
||||
## RAFT
|
||||
|
||||
ToDo
|
||||
Currently work-in-progress, see [Roadmap](https://github.com/qdrant/qdrant/blob/master/docs/roadmap/README.md)
|
||||
|
||||
@@ -38,8 +38,8 @@ Example:
|
||||
{
|
||||
"filter": {
|
||||
"must": [
|
||||
{ "key": "city", "match": { "keyword": "London" } },
|
||||
{ "key": "color", "match": { "keyword": "red" } }
|
||||
{ "key": "city", "match": { "value": "London" } },
|
||||
{ "key": "color", "match": { "value": "red" } }
|
||||
]
|
||||
}
|
||||
...
|
||||
@@ -66,8 +66,8 @@ Example:
|
||||
{
|
||||
"filter": {
|
||||
"should": [
|
||||
{ "key": "city", "match": { "keyword": "London" } },
|
||||
{ "key": "color", "match": { "keyword": "red" } }
|
||||
{ "key": "city", "match": { "value": "London" } },
|
||||
{ "key": "color", "match": { "value": "red" } }
|
||||
]
|
||||
}
|
||||
...
|
||||
@@ -97,8 +97,8 @@ Example:
|
||||
{
|
||||
"filter": {
|
||||
"must_not": [
|
||||
{ "key": "city", "match": { "keyword": "London" } },
|
||||
{ "key": "color", "match": { "keyword": "red" } }
|
||||
{ "key": "city", "match": { "value": "London" } },
|
||||
{ "key": "color", "match": { "value": "red" } }
|
||||
]
|
||||
}
|
||||
...
|
||||
@@ -126,10 +126,10 @@ It is also possible to use several clauses simultaneously:
|
||||
{
|
||||
"filter": {
|
||||
"must": [
|
||||
{ "key": "city", "match": { "keyword": "London" } }
|
||||
{ "key": "city", "match": { "value": "London" } }
|
||||
],
|
||||
"must_not": [
|
||||
{ "key": "color", "match": { "keyword": "red" } }
|
||||
{ "key": "color", "match": { "value": "red" } }
|
||||
]
|
||||
}
|
||||
...
|
||||
@@ -155,8 +155,8 @@ Also the conditions could be recursively nested. Example:
|
||||
"must_not": [
|
||||
{
|
||||
"must": [
|
||||
{ "key": "city", "match": { "keyword": "London" } },
|
||||
{ "key": "color", "match": { "keyword": "red" } }
|
||||
{ "key": "city", "match": { "value": "London" } },
|
||||
{ "key": "color", "match": { "value": "red" } }
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -188,7 +188,7 @@ Let's look at the existing condition variants and what types of data they apply
|
||||
{
|
||||
"key": "color",
|
||||
"match": {
|
||||
"keyword": "red"
|
||||
"value": "red"
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -197,13 +197,15 @@ Let's look at the existing condition variants and what types of data they apply
|
||||
{
|
||||
"key": "count",
|
||||
"match": {
|
||||
"integer": 0
|
||||
"value": 0
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
The simplest kind of condition is one that checks if the stored value equals the given one. If several values are stored, at least one of them should match the condition. You can apply it to payloads of type `keyword` or `integer`.
|
||||
The simplest kind of condition is one that checks if the stored value equals the given one.
|
||||
If several values are stored, at least one of them should match the condition.
|
||||
You can apply it to [keyword](../payload/#keyword), [integer](../payload/#integer) and [bool](../payload/#bool) payloads.
|
||||
|
||||
### Range
|
||||
|
||||
@@ -229,10 +231,12 @@ Comparisons that can be used:
|
||||
- `lt` - less than
|
||||
- `lte` - less than or equal
|
||||
|
||||
Can be applied to payloads of type `float` or `integer`.
|
||||
Can be applied to [float](../payload/#float) and [integer](../payload/#integer) payloads.
|
||||
|
||||
### Geo
|
||||
|
||||
#### Geo Bounding Box
|
||||
|
||||
```
|
||||
{
|
||||
"key": "location",
|
||||
@@ -253,6 +257,8 @@ Can be applied to payloads of type `float` or `integer`.
|
||||
It matches with `location`s inside a rectangle with the coordinates of the upper left corner in `bottom_right` and the coordinates of the lower right corner in `top_left`.
|
||||
|
||||
|
||||
#### Geo Radius
|
||||
|
||||
```
|
||||
{
|
||||
"key": "location",
|
||||
@@ -269,8 +275,58 @@ It matches with `location`s inside a rectangle with the coordinates of the upper
|
||||
It matches with `location`s inside a circle with the `center` at the center and a radius of `radius` meters.
|
||||
|
||||
If several values are stored, at least one of them should match the condition.
|
||||
These conditions can only be applied to payloads of the `geo` type.
|
||||
These conditions can only be applied to payloads that match the [geo-data format](../payload/#geo).
|
||||
|
||||
### Values count
|
||||
|
||||
In addition to the direct value comparison, it is also possible to filter by the amount of values.
|
||||
|
||||
For example, given the data:
|
||||
|
||||
```
|
||||
[
|
||||
{"id": 1, "name": "product A", "comments": ["Very good!", "Excellent"]},
|
||||
{"id": 2, "name": "product B", "comments": ["meh", "expected more", "ok"]},
|
||||
]
|
||||
```
|
||||
|
||||
We can perform the search only among the items with more than two comments:
|
||||
|
||||
```
|
||||
{
|
||||
"key": "comments",
|
||||
"values_count": {
|
||||
"gt": 2
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The result would be:
|
||||
|
||||
```
|
||||
[
|
||||
{"id": 2, "name": "product B", "comments": ["meh", "expected more", "ok"]},
|
||||
]
|
||||
```
|
||||
|
||||
If stored value is not an array - it is assumed that the amount of values is equals to 1.
|
||||
|
||||
### Is Empty
|
||||
|
||||
Sometimes it is also useful to filter out records that are missing some value.
|
||||
The `IsEmpty` condition may help you with that:
|
||||
|
||||
```
|
||||
{
|
||||
"is_empty": {
|
||||
"key": "reports"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This condition will match all records where the field `reports` either does not exists, or have `NULL` or `[]` value.
|
||||
|
||||
<aside role="status">The <b>IsEmpty</b> is often useful together with the logical negation <b>must_not<b>. In this case all non-empty values will be selected.</aside>
|
||||
|
||||
### Has id
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ Their necessity is determined by the [optimizer](../optimizer) settings and depe
|
||||
## Payload Index
|
||||
|
||||
Payload index in Qdrant is similar to the index in conventional document-oriented databases.
|
||||
This index is built for a specific field and is used for quick point requests by the corresponding filtering condition.
|
||||
This index is built for a specific field and type and is used for quick point requests by the corresponding filtering condition.
|
||||
|
||||
The index is also used to accurately estimate the filter cardinality, which helps the [query planned](../search) choose a search strategy.
|
||||
|
||||
@@ -28,7 +28,8 @@ REST API
|
||||
PUT /collections/{collection_name}/index
|
||||
|
||||
{
|
||||
"field_name": "name_of_the_field_to_index"
|
||||
"field_name": "name_of_the_field_to_index",
|
||||
"field_type": "keyword"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -39,8 +40,15 @@ With Python client
|
||||
```
|
||||
-->
|
||||
|
||||
Available field types are:
|
||||
|
||||
* `keyword` - for [keyword](../payload/#keyword) payload, affects [Match](../filtering/#match) filtering conditions.
|
||||
* `integer` - for [integer](../payload/#integer) payload, affects [Match](../filtering/#match) and [Range](../filtering/#range) filtering conditions.
|
||||
* `float` - for [float](../payload/#float) payload, affects [Range](../filtering/#range) filtering conditions.
|
||||
* `geo` - for [geo](../payload/#geo) payload, affects [Geo Bounding Box](../filtering/#geo-bounding-box) and [Geo Radius](../filtering/#geo-radius) filtering conditions.
|
||||
|
||||
For indexing, it is recommended to choose the field that limits the search result the most.
|
||||
As a rule, the more different values a payload value has, the more efficient the index will be used.
|
||||
As a rule, the more different values a payload value has, the more efficiently the index will be used.
|
||||
You should not create an index for Boolean fields and fields with only a few possible values.
|
||||
|
||||
|
||||
|
||||
@@ -3,69 +3,138 @@ title: Payload
|
||||
weight: 25
|
||||
---
|
||||
|
||||
One of the significant features of Qdrant is the ability to store additional values along with vectors.
|
||||
These values are called `payload` in Qdrant terminology.
|
||||
A payload is a set of key-value data. Each key can have several values of the same type.
|
||||
One of the significant features of Qdrant is the ability to store additional information along with vectors.
|
||||
This information is called `payload` in Qdrant terminology.
|
||||
|
||||
Qdrant allows you to store any information that can be represented using JSON.
|
||||
|
||||
Here is an example of a typical payload:
|
||||
|
||||
Here is an example of a typical payload represented in JSON:
|
||||
```json
|
||||
{
|
||||
"name": "jacket",
|
||||
"colors": ["red", "blue"],
|
||||
"count": 10,
|
||||
"price": 11.99,
|
||||
"locations": [
|
||||
{
|
||||
"lon": 52.5200,
|
||||
"lat": 13.4050
|
||||
}
|
||||
],
|
||||
"reviews": [
|
||||
{
|
||||
"user": "alice",
|
||||
"score": 4
|
||||
},
|
||||
{
|
||||
"user": "bob",
|
||||
"score": 5
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Qdrant will try to recognize the value type for each key automatically, but you can also specify it explicitly:
|
||||
## Payload types
|
||||
|
||||
```json
|
||||
{
|
||||
"colors": {
|
||||
"type": "keyword",
|
||||
"value": ["red", "blue"]
|
||||
},
|
||||
"price": {
|
||||
"type": "float",
|
||||
"value": 11.99
|
||||
},
|
||||
"locations": {
|
||||
"type": "geo",
|
||||
"value": [
|
||||
{
|
||||
"lon": 52.5200,
|
||||
"lat": 13.4050
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Here are the types of value that are currently available in Qdrant:
|
||||
|
||||
* `integer` - 64-bit integer in the range `-9223372036854775808` to `9223372036854775807`.
|
||||
* `float` - 64-bit floating point number.
|
||||
* `keyword` - string value.
|
||||
* `geo` - Geographical coordinates. Example: `{ "lon": 52.5200, "lat": 13.4050 }`
|
||||
|
||||
Values corresponding to the same key in different records must have the same type.
|
||||
|
||||
In other words, it is impossible to have one vector associated with payload `{"price": 11.99}`, and another vector associated with `{"price": "cheap"}`.
|
||||
To maintain type consistency, Qdrant has a payload schema associated with the collection.
|
||||
This schema is available at the [collection info API](https://qdrant.github.io/qdrant/redoc/index.html#operation/get_collection)
|
||||
|
||||
## Payload filtered search
|
||||
|
||||
Qdrant stores payload along with vectors and allows you to search based on its values.
|
||||
In addition to storing payloads, Qdrant also allows you search based on certain kinds of values.
|
||||
This feature is implemented as additional filters during the search and will enable you to incorporate custom logic on top of semantic similarity.
|
||||
|
||||
During the filtering, Qdrant will check the conditions over those values that match the type of the filtering condition. If the stored value type does not fit the filtering condition - it will be considered not satisfied.
|
||||
|
||||
For example, you will get an empty output if you apply the [range condition](../filtering/#range) on the string data.
|
||||
|
||||
Qdrant also allows multiple values of the same type to be stored and applied to the filter at once.
|
||||
The condition will be considered satisfied if at least one value meets the condition.
|
||||
|
||||
The filtering process is discussed in detail in the section [Filtering](../filtering).
|
||||
|
||||
Let's look at the data types that Qdrant supports for searching:
|
||||
|
||||
### Integer
|
||||
|
||||
`integer` - 64-bit integer in the range from `-9223372036854775808` to `9223372036854775807`.
|
||||
|
||||
|
||||
Example of single and multiple `integer` values:
|
||||
|
||||
```json
|
||||
{
|
||||
"count": 10,
|
||||
"sizes": [35, 36, 38]
|
||||
}
|
||||
```
|
||||
|
||||
### Float
|
||||
|
||||
`float` - 64-bit floating point number.
|
||||
|
||||
|
||||
Example of single and multiple `float` values:
|
||||
|
||||
```json
|
||||
{
|
||||
"price": 11.99,
|
||||
"ratings": [9.1, 9.2, 9.4]
|
||||
}
|
||||
```
|
||||
|
||||
### Bool
|
||||
|
||||
Bool - is binary value equals to `true` or `false`.
|
||||
|
||||
Example of single and multiple `bool` values:
|
||||
|
||||
```json
|
||||
{
|
||||
"is_delivered": true,
|
||||
"responses": [false, false, true, false]
|
||||
}
|
||||
```
|
||||
|
||||
### Keyword
|
||||
|
||||
`keyword` - string value.
|
||||
|
||||
Example of single and multiple `keyword` values:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "Alice",
|
||||
"friends": [
|
||||
"bob",
|
||||
"eva",
|
||||
"jack"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Geo
|
||||
|
||||
`geo` is used to represent geographical coordinates.
|
||||
|
||||
Example of single and multiple `geo` values:
|
||||
|
||||
```json
|
||||
{
|
||||
"location": {
|
||||
"lon": 52.5200,
|
||||
"lat": 13.4050
|
||||
},
|
||||
"cities": [
|
||||
{
|
||||
"lon": 51.5072,
|
||||
"lat": 0.1276
|
||||
},
|
||||
{
|
||||
"lon": 40.7128,
|
||||
"lat": 74.0060
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Coordinate should be described as an object containing two fields: `lon` - for longitude, and `lat` - for latitude.
|
||||
|
||||
## Create point with payload
|
||||
|
||||
@@ -192,7 +261,7 @@ For example, building an index for the object ID (if it is used in the filter) w
|
||||
|
||||
In compound queries involving multiple fields, Qdrant will attempt to use the most restrictive index first.
|
||||
|
||||
To mark a field as indexable, you can use the following:
|
||||
To create index for the field, you can use the following:
|
||||
|
||||
REST API
|
||||
|
||||
@@ -200,7 +269,8 @@ REST API
|
||||
PUT /collections/{collection_name}/index
|
||||
|
||||
{
|
||||
"field_name": "name_of_the_field_to_index"
|
||||
"field_name": "name_of_the_field_to_index",
|
||||
"field_type": "keyword"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -219,17 +289,11 @@ Payload schema example:
|
||||
{
|
||||
"payload_schema": {
|
||||
"property1": {
|
||||
"data_type": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"indexed": true
|
||||
"data_type": "keyword"
|
||||
},
|
||||
"property2": {
|
||||
"data_type": {
|
||||
"type": "integer"
|
||||
},
|
||||
"indexed": false
|
||||
"data_type": "integer"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
@@ -296,7 +296,7 @@ POST /collections/{collection_name}/points/delete
|
||||
{
|
||||
"key": "color"
|
||||
"match": {
|
||||
"keyword": "red"
|
||||
"value": "red"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -366,7 +366,7 @@ POST /collections/{collection_name}/points/scroll
|
||||
{
|
||||
"key": "color",
|
||||
"match": {
|
||||
"keyword": "red"
|
||||
"value": "red"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -387,7 +387,7 @@ Returns all point with `color` = `red`.
|
||||
{
|
||||
"id": 0,
|
||||
"payload": {
|
||||
"color": { "type": "keyword", "value": [ "red" ] }
|
||||
"color": "red"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -111,11 +111,11 @@ curl -L -X PUT 'http://localhost:6333/collections/test_collection/points?wait=tr
|
||||
-H 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"points": [
|
||||
{"id": 1, "vector": [0.05, 0.61, 0.76, 0.74], "payload": {"city": {"type": "keyword", "value": "Berlin"}}},
|
||||
{"id": 2, "vector": [0.19, 0.81, 0.75, 0.11], "payload": {"city": {"type": "keyword", "value": ["Berlin", "London"] }}},
|
||||
{"id": 3, "vector": [0.36, 0.55, 0.47, 0.94], "payload": {"city": {"type": "keyword", "value": ["Berlin", "Moscow"] }}},
|
||||
{"id": 4, "vector": [0.18, 0.01, 0.85, 0.80], "payload": {"city": {"type": "keyword", "value": ["London", "Moscow"]}}},
|
||||
{"id": 5, "vector": [0.24, 0.18, 0.22, 0.44], "payload": {"count": {"type": "integer", "value": [0]}}},
|
||||
{"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]}
|
||||
]
|
||||
}'
|
||||
@@ -171,7 +171,7 @@ curl -L -X POST 'http://localhost:6333/collections/test_collection/points/search
|
||||
{
|
||||
"key": "city",
|
||||
"match": {
|
||||
"keyword": "London"
|
||||
"value": "London"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -68,7 +68,7 @@ POST /collections/{collection_name}/points/search
|
||||
{
|
||||
"key": "city",
|
||||
"match": {
|
||||
"keyword": "London"
|
||||
"value": "London"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -145,7 +145,7 @@ POST /collections/{collection_name}/points/search
|
||||
|
||||
## Recommendation API
|
||||
|
||||
<aside role="alert">Negative vectors is an experimental functionality that is not guaranteed to work with all kind of embeddings.</aside>
|
||||
**DISCLAIMER**: Negative vectors is an experimental functionality that is not guaranteed to work with all king of embeddings.
|
||||
|
||||
In addition to the regular search, Qdrant also allows you to search based on multiple already stored data collection vectors.
|
||||
This API allows using vector search without using a neural network encoder for already encoded objects.
|
||||
@@ -169,7 +169,7 @@ POST /collections/{collection_name}/points/recommend
|
||||
{
|
||||
"key": "city",
|
||||
"match": {
|
||||
"keyword": "London"
|
||||
"value": "London"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user