Always test for collections

This commit is contained in:
Cyber MacGeddon 2025-09-30 00:23:23 +01:00
parent ca86601c2d
commit ae51a00d31
4 changed files with 16 additions and 4 deletions

View file

@ -42,7 +42,8 @@ class Processor(DocumentEmbeddingsQueryService):
def ensure_collection_exists(self, collection, dim):
"""Ensure collection exists, create if it doesn't"""
if collection != self.last_collection:
# Always check if collection exists, even if cached
if collection != self.last_collection or not self.qdrant.collection_exists(collection):
if not self.qdrant.collection_exists(collection):
try:
self.qdrant.create_collection(

View file

@ -42,7 +42,8 @@ class Processor(GraphEmbeddingsQueryService):
def ensure_collection_exists(self, collection, dim):
"""Ensure collection exists, create if it doesn't"""
if collection != self.last_collection:
# Always check if collection exists, even if cached
if collection != self.last_collection or not self.qdrant.collection_exists(collection):
if not self.qdrant.collection_exists(collection):
try:
self.qdrant.create_collection(

View file

@ -94,7 +94,8 @@ class Processor(DocumentEmbeddingsStoreService):
message.metadata.collection
)
if collection != self.last_collection:
# Always check if collection exists, even if cached
if collection != self.last_collection or not self.qdrant.collection_exists(collection):
if not self.qdrant.collection_exists(collection):
@ -176,6 +177,10 @@ class Processor(DocumentEmbeddingsStoreService):
if self.qdrant.collection_exists(collection_name):
self.qdrant.delete_collection(collection_name)
logger.info(f"Deleted Qdrant collection: {collection_name}")
# Clear cache if we just deleted the cached collection
if self.last_collection == collection_name:
self.last_collection = None
else:
logger.info(f"Collection {collection_name} does not exist, nothing to delete")

View file

@ -77,7 +77,8 @@ class Processor(GraphEmbeddingsStoreService):
"t_" + user + "_" + collection
)
if cname != self.last_collection:
# Always check if collection exists, even if cached
if cname != self.last_collection or not self.qdrant.collection_exists(cname):
if not self.qdrant.collection_exists(cname):
@ -183,6 +184,10 @@ class Processor(GraphEmbeddingsStoreService):
if self.qdrant.collection_exists(collection_name):
self.qdrant.delete_collection(collection_name)
logger.info(f"Deleted Qdrant collection: {collection_name}")
# Clear cache if we just deleted the cached collection
if self.last_collection == collection_name:
self.last_collection = None
else:
logger.info(f"Collection {collection_name} does not exist, nothing to delete")