drop and recreate tables on reindex

This commit is contained in:
Josh Hawkins 2024-10-09 13:42:42 -05:00
parent 010d204b43
commit c87bdb4d26

View File

@ -150,6 +150,14 @@ class Embeddings:
); );
""") """)
def _drop_tables(self):
self.db.execute_sql("""
DROP TABLE vec_descriptions;
""")
self.db.execute_sql("""
DROP TABLE vec_thumbnails;
""")
def upsert_thumbnail(self, event_id: str, thumbnail: bytes): def upsert_thumbnail(self, event_id: str, thumbnail: bytes):
# Convert thumbnail bytes to PIL Image # Convert thumbnail bytes to PIL Image
image = Image.open(io.BytesIO(thumbnail)).convert("RGB") image = Image.open(io.BytesIO(thumbnail)).convert("RGB")
@ -281,6 +289,9 @@ class Embeddings:
def reindex(self) -> None: def reindex(self) -> None:
logger.info("Indexing event embeddings...") logger.info("Indexing event embeddings...")
self._drop_tables()
self._create_tables()
st = time.time() st = time.time()
totals = { totals = {
"thumb": 0, "thumb": 0,