@@ -326,7 +326,8 @@ def count_documents(self) -> int:
326326 total = self .collection .aggregate .over_all (total_count = True ).total_count
327327 return total if total else 0
328328
329- def _to_data_object (self , document : Document ) -> dict [str , Any ]:
329+ @staticmethod
330+ def _to_data_object (document : Document ) -> dict [str , Any ]:
330331 """
331332 Converts a Document to a Weaviate data object ready to be saved.
332333 """
@@ -365,7 +366,8 @@ def _to_data_object(self, document: Document) -> dict[str, Any]:
365366
366367 return data
367368
368- def _to_document (self , data : DataObject [dict [str , Any ], None ]) -> Document :
369+ @staticmethod
370+ def _to_document (data : DataObject [dict [str , Any ], None ]) -> Document :
369371 """
370372 Converts a data object read from Weaviate into a Document.
371373 """
@@ -460,7 +462,7 @@ def filter_documents(self, filters: Optional[dict[str, Any]] = None) -> list[Doc
460462 result = self ._query_with_filters (filters )
461463 else :
462464 result = self ._query ()
463- return [self ._to_document (doc ) for doc in result ]
465+ return [WeaviateDocumentStore ._to_document (doc ) for doc in result ]
464466
465467 def _batch_write (self , documents : list [Document ]) -> int :
466468 """
@@ -476,7 +478,7 @@ def _batch_write(self, documents: list[Document]) -> int:
476478 raise ValueError (msg )
477479
478480 batch .add_object (
479- properties = self ._to_data_object (doc ),
481+ properties = WeaviateDocumentStore ._to_data_object (doc ),
480482 collection = self .collection .name ,
481483 uuid = generate_uuid5 (doc .id ),
482484 vector = doc .embedding ,
@@ -524,7 +526,7 @@ def _write(self, documents: list[Document], policy: DuplicatePolicy) -> int:
524526 try :
525527 self .collection .data .insert (
526528 uuid = generate_uuid5 (doc .id ),
527- properties = self ._to_data_object (doc ),
529+ properties = WeaviateDocumentStore ._to_data_object (doc ),
528530 vector = doc .embedding ,
529531 )
530532
@@ -848,7 +850,7 @@ def _bm25_retrieval(
848850 return_metadata = ["score" ],
849851 )
850852
851- return [self ._to_document (doc ) for doc in result .objects ]
853+ return [WeaviateDocumentStore ._to_document (doc ) for doc in result .objects ]
852854
853855 async def _bm25_retrieval_async (
854856 self , query : str , filters : Optional [dict [str , Any ]] = None , top_k : Optional [int ] = None
@@ -866,7 +868,7 @@ async def _bm25_retrieval_async(
866868 return_metadata = ["score" ],
867869 )
868870
869- return [self ._to_document (doc ) for doc in result .objects ]
871+ return [WeaviateDocumentStore ._to_document (doc ) for doc in result .objects ]
870872
871873 def _embedding_retrieval (
872874 self ,
@@ -892,7 +894,7 @@ def _embedding_retrieval(
892894 return_metadata = ["certainty" ],
893895 )
894896
895- return [self ._to_document (doc ) for doc in result .objects ]
897+ return [WeaviateDocumentStore ._to_document (doc ) for doc in result .objects ]
896898
897899 async def _embedding_retrieval_async (
898900 self ,
@@ -920,7 +922,7 @@ async def _embedding_retrieval_async(
920922 return_metadata = ["certainty" ],
921923 )
922924
923- return [self ._to_document (doc ) for doc in result .objects ]
925+ return [WeaviateDocumentStore ._to_document (doc ) for doc in result .objects ]
924926
925927 def _hybrid_retrieval (
926928 self ,
@@ -945,7 +947,7 @@ def _hybrid_retrieval(
945947 return_metadata = ["score" ],
946948 )
947949
948- return [self ._to_document (doc ) for doc in result .objects ]
950+ return [WeaviateDocumentStore ._to_document (doc ) for doc in result .objects ]
949951
950952 async def _hybrid_retrieval_async (
951953 self ,
@@ -972,4 +974,4 @@ async def _hybrid_retrieval_async(
972974 return_metadata = ["score" ],
973975 )
974976
975- return [self ._to_document (doc ) for doc in result .objects ]
977+ return [WeaviateDocumentStore ._to_document (doc ) for doc in result .objects ]
0 commit comments