From c204fadd2ceaca2f250613a9744fa86cbbbf1c3c Mon Sep 17 00:00:00 2001 From: Paul Sanders Date: Fri, 5 Jan 2024 15:52:28 -0500 Subject: [PATCH] Specify primary key for Meilisearch (#666) --- .../continuedev/libs/index/indices/meilisearch_index.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/server/continuedev/libs/index/indices/meilisearch_index.py b/server/continuedev/libs/index/indices/meilisearch_index.py index 634844911..f990cd934 100644 --- a/server/continuedev/libs/index/indices/meilisearch_index.py +++ b/server/continuedev/libs/index/indices/meilisearch_index.py @@ -76,7 +76,8 @@ class MeilisearchCodebaseIndex(CodebaseIndex): chunk, int(chunk.digest, 16), [self.tag] ) for chunk in chunks - ] + ], + primary_key="id", ) async def delete_chunks(self, document_ids: List[str], index: Index): @@ -98,14 +99,14 @@ class MeilisearchCodebaseIndex(CodebaseIndex): for document in documents: document["tags"].remove(label) - await index.update_documents(documents) + await index.update_documents(documents, primary_key="id") async def add_label(self, digest: str, label: str, index: Index): documents = (await self.get_docs_for_digest(digest, index)).results for document in documents: document["tags"].append(label) - await index.update_documents(documents) + await index.update_documents(documents, primary_key="id") async def build( self, chunks: AsyncGenerator[Tuple[IndexAction, Union[str, Chunk]], None] @@ -113,7 +114,7 @@ class MeilisearchCodebaseIndex(CodebaseIndex): """Builds the index, yielding progress as a float between 0 and 1""" async with Client(get_meilisearch_url()) as search_client: try: - await search_client.create_index(self.index_name) + await search_client.create_index(self.index_name, primary_key="id") index = await search_client.get_index(self.index_name) # await index.update_ranking_rules( # ["attribute", "words", "typo", "proximity", "sort", "exactness"]