Skip to content

Commit 158c5eb

Browse files
committed
fix: image search 500 on Qdrant Cloud
- Missing collection_id payload index on the image collection — Qdrant Cloud rejects filters on unindexed fields (local docker tolerated it) - ensure_collections now runs at app startup, not just first ingest
1 parent 6125719 commit 158c5eb

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

backend/app/main.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import asyncio
12
from contextlib import asynccontextmanager
23

34
from arq import create_pool
@@ -7,12 +8,15 @@
78

89
from app.api import chat, collections, documents, health
910
from app.core.config import get_settings
11+
from app.retrieval.vectorstore import ensure_collections
1012

1113

1214
@asynccontextmanager
1315
async def lifespan(app: FastAPI):
1416
settings = get_settings()
1517
app.state.arq = await create_pool(RedisSettings.from_dsn(settings.redis_url))
18+
# collections + payload indexes must exist before any search hits them
19+
await asyncio.to_thread(ensure_collections)
1620
yield
1721
await app.state.arq.close()
1822

backend/app/retrieval/vectorstore.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ def ensure_collections() -> None:
4949
client.create_payload_index(
5050
IMAGE_COLLECTION, "tenant_id", models.PayloadSchemaType.KEYWORD
5151
)
52+
client.create_payload_index(
53+
IMAGE_COLLECTION, "collection_id", models.PayloadSchemaType.KEYWORD
54+
)
5255

5356

5457
def _tenant_filter(tenant_id: str, collection_id: str | None) -> models.Filter:

0 commit comments

Comments
 (0)