Spaces:
Runtime error
Runtime error
Delete tests
Browse files- tests/add_index_to_qdrant.py +0 -46
tests/add_index_to_qdrant.py
DELETED
|
@@ -1,46 +0,0 @@
|
|
| 1 |
-
from qdrant_client import QdrantClient, models
|
| 2 |
-
from config import settings
|
| 3 |
-
import logging
|
| 4 |
-
|
| 5 |
-
logging.basicConfig(level=logging.INFO)
|
| 6 |
-
|
| 7 |
-
# Connect to your Qdrant Cloud instance
|
| 8 |
-
client = QdrantClient(
|
| 9 |
-
url=settings.qdrant_url,
|
| 10 |
-
api_key=settings.qdrant_api_key,
|
| 11 |
-
)
|
| 12 |
-
|
| 13 |
-
collection_name = "anime_collection"
|
| 14 |
-
|
| 15 |
-
logging.info("Creating payload indices...")
|
| 16 |
-
|
| 17 |
-
# 1. Index for scored_by (Integer)
|
| 18 |
-
client.create_payload_index(
|
| 19 |
-
collection_name=collection_name,
|
| 20 |
-
field_name="scored_by",
|
| 21 |
-
field_schema=models.PayloadSchemaType.INTEGER,
|
| 22 |
-
)
|
| 23 |
-
|
| 24 |
-
# 2. Index for score (Float)
|
| 25 |
-
client.create_payload_index(
|
| 26 |
-
collection_name=collection_name,
|
| 27 |
-
field_name="score",
|
| 28 |
-
field_schema=models.PayloadSchemaType.FLOAT,
|
| 29 |
-
)
|
| 30 |
-
|
| 31 |
-
# 3. Index for type (String/Keyword)
|
| 32 |
-
client.create_payload_index(
|
| 33 |
-
collection_name=collection_name,
|
| 34 |
-
field_name="type",
|
| 35 |
-
field_schema=models.PayloadSchemaType.KEYWORD,
|
| 36 |
-
)
|
| 37 |
-
|
| 38 |
-
# 4. Index for genres (List of Strings -> Keyword)
|
| 39 |
-
# Note: Qdrant automatically handles arrays of strings as Keyword indices!
|
| 40 |
-
client.create_payload_index(
|
| 41 |
-
collection_name=collection_name,
|
| 42 |
-
field_name="genres",
|
| 43 |
-
field_schema=models.PayloadSchemaType.KEYWORD,
|
| 44 |
-
)
|
| 45 |
-
|
| 46 |
-
logging.info("✅ All payload indices created successfully!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|