Files
qdrant/tests/basic_sparse_test.sh
Ivan Pleshkov 336efea59e Sparse index segment and collection config (#2802)
* quantization storage as separate entity

sparse index try to extend segment types

fix build

fix async scorer

codespell

update openapi

update vector index

remove code duplications

more fixes

more fixes

fix build

fix deserialization test

remove transform_into

are you happy clippy

update openapi

update openapi

are you happy clippy

fix build

optional serialize

more defaults

update openapi

fix comments

generic transpose_map_into_named_vector

rename fields in tests

remove obsolete parts

only named sparse config

VectorStruct without unnamed sparse

NamedVectorStruct without unnamed sparse

remove obsolete test

update openapi

mmap index

revert preprocess function

are you happy fmt

update openapi

fix build

fix tests

are you happy fmt

fix for client generation

fix sparse segment creation

fix basic sparse test

fix conflicts

remove obsolete convertion

fix build

config diffs

update openapi

review remarks

update openapi

fix batch upsert

add failing test showing bad ids matching

fix sparse vector insertion

remove on_disk flag

update openapi

revert debug assert

simplify conversions

update openapi

remove on disk storage flag

update openapi

default for vector config

update openapi comment

remove diffs

update openapi

* enable consensus test

* add comment

* update openapi
2023-12-01 13:10:58 +01:00

217 lines
5.4 KiB
Bash
Executable File

#!/bin/bash
# This test checks that Qdrant answers to all API mentioned in README.md as expected
set -ex
QDRANT_HOST=${QDRANT_HOST:-'localhost:6333'}
COLLECTION_NAME=${COLLECTION_NAME:-'sparse_collection'}
# cleanup collection if it exists
curl -X DELETE "http://$QDRANT_HOST/collections/$COLLECTION_NAME" \
-H 'Content-Type: application/json' \
--fail -s \
--fail -s | jq
# TODO(sparse) add validation and tests for case where dense and sparse vectors have the same name
# create collection
curl -X PUT "http://$QDRANT_HOST/collections/$COLLECTION_NAME" \
-H 'Content-Type: application/json' \
--fail -s \
--data-raw '{
"sparse_vectors": {
"text": { }
},
"optimizers_config": {
"default_segment_number": 2
},
"replication_factor": 2
}' | jq
curl -L -X PUT "http://$QDRANT_HOST/collections/$COLLECTION_NAME/index" \
-H 'Content-Type: application/json' \
--fail -s \
--data-raw '{
"field_name": "city",
"field_schema": "keyword"
}' | jq
curl -L -X PUT "http://$QDRANT_HOST/collections/$COLLECTION_NAME/index" \
-H 'Content-Type: application/json' \
--fail -s \
--data-raw '{
"field_name": "count",
"field_schema": "integer"
}' | jq
curl -L -X PUT "http://$QDRANT_HOST/collections/$COLLECTION_NAME/index" \
-H 'Content-Type: application/json' \
--fail -s \
--data-raw '{
"field_name": "coords",
"field_schema": "geo"
}' | jq
curl --fail -s "http://$QDRANT_HOST/collections/$COLLECTION_NAME" | jq
# insert points
curl -L -X PUT "http://$QDRANT_HOST/collections/$COLLECTION_NAME/points?wait=true" \
-H 'Content-Type: application/json' \
--fail -s \
--data-raw '{
"points": [
{
"id": 1,
"vector": {
"text": {
"values": [0.05, 0.61, 0.76, 0.74],
"indices": [0, 1, 2, 3]
}
},
"payload": {
"city": "Berlin",
"country": "Germany" ,
"count": 1000000,
"square": 12.5,
"coords": { "lat": 1.0, "lon": 2.0 }
}
},
{
"id": 2,
"vector": {
"text": {
"values": [0.19, 0.81, 0.75, 0.11],
"indices": [0, 1, 2, 3]
}
},
"payload": {"city": ["Berlin", "London"]}
},
{
"id": 3,
"vector": {
"text": {
"values": [0.36, 0.55, 0.47, 0.94],
"indices": [0, 1, 2, 3]
}
},
"payload": {"city": ["Berlin", "Moscow"]}
},
{
"id": 4,
"vector": {
"text": {
"values": [0.18, 0.01, 0.85, 0.80],
"indices": [0, 1, 2, 3]
}
},
"payload": {"city": ["London", "Moscow"]}
},
{
"id": "98a9a4b1-4ef2-46fb-8315-a97d874fe1d7",
"vector": {
"text": {
"values": [0.24, 0.18, 0.22, 0.44],
"indices": [0, 1, 2, 3]
}
},
"payload": {"count": [0]}
},
{
"id": "f0e09527-b096-42a8-94e9-ea94d342b925",
"vector": {
"text": {
"values": [0.35, 0.08, 0.11, 0.44],
"indices": [0, 1, 2, 3]
}
}
}
]
}' | jq
# retrieve point
curl -L -X GET "http://$QDRANT_HOST/collections/$COLLECTION_NAME/points/2" \
-H 'Content-Type: application/json' \
--fail -s | jq
# retrieve points
curl -L -X POST "http://$QDRANT_HOST/collections/$COLLECTION_NAME/points" \
-H 'Content-Type: application/json' \
--fail -s \
--data-raw '{
"ids": [1, 2],
"with_vectors": true
}' | jq
SAVED_VECTORS_COUNT=$(curl --fail -s "http://$QDRANT_HOST/collections/$COLLECTION_NAME" | jq '.result.vectors_count')
[[ "$SAVED_VECTORS_COUNT" == "6" ]] || {
echo 'check failed - 6 points expected'
exit 1
}
# search points
curl -L -X POST "http://$QDRANT_HOST/collections/$COLLECTION_NAME/points/search" \
-H 'Content-Type: application/json' \
--fail -s \
--data-raw '{
"vector": {
"name": "text",
"vector": {
"values": [0.2, 0.1, 0.9, 0.7],
"indices": [0, 1, 2, 3]
}
},
"top": 3
}' | jq
# search points batch
curl -L -X POST "http://$QDRANT_HOST/collections/$COLLECTION_NAME/points/search/batch" \
-H 'Content-Type: application/json' \
--fail -s \
--data-raw '{
"searches": [
{
"vector": {
"name": "text",
"vector": {
"values": [0.2, 0.1, 0.9, 0.7],
"indices": [0, 1, 2, 3]
}
},
"top": 3
},
{
"vector": {
"name": "text",
"vector": {
"values": [0.2 ,0.1, 0.9, 0.7],
"indices": [0, 1, 2, 3]
}
},
"top": 3
}
]
}' | jq
curl -L -X POST "http://$QDRANT_HOST/collections/$COLLECTION_NAME/points/search" \
-H 'Content-Type: application/json' \
--fail -s \
--data-raw '{
"filter": {
"should": [
{
"key": "city",
"match": {
"value": "London"
}
}
]
},
"vector": {
"name": "text",
"vector": {
"values": [0.2, 0.1, 0.9, 0.7],
"indices": [0, 1, 2, 3]
}
},
"top": 3
}' | jq