@@ -135,6 +135,8 @@ def __init__(
135135 payload_fields_to_index : Optional [List [dict ]] = None ,
136136 ) -> None :
137137 """
138+ Initialize a QdrantDocumentStore.
139+
138140 :param location:
139141 If `":memory:"` - use in-memory Qdrant instance.
140142 If `str` - use it as a URL parameter.
@@ -345,12 +347,13 @@ def filter_documents(
345347 [documentation](https://docs.haystack.deepset.ai/docs/metadata-filtering)
346348
347349 :param filters: The filters to apply to the document list.
348- :returns: A list of documents that match the given filters.
350+ :returns:
351+ A list of documents that match the given filters.
349352 """
350353 # No need to initialize client here as _get_documents_generator
351354 # will handle client initialization internally
352355
353- self ._validate_filters (filters )
356+ QdrantDocumentStore ._validate_filters (filters )
354357 return list (
355358 self ._get_documents_generator (
356359 filters ,
@@ -367,7 +370,7 @@ async def filter_documents_async(
367370 # No need to initialize client here as _get_documents_generator_async
368371 # will handle client initialization internally
369372
370- self ._validate_filters (filters )
373+ QdrantDocumentStore ._validate_filters (filters )
371374 return [doc async for doc in self ._get_documents_generator_async (filters )]
372375
373376 def write_documents (
@@ -430,6 +433,7 @@ async def write_documents_async(
430433 ) -> int :
431434 """
432435 Asynchronously writes documents to Qdrant using the specified policy.
436+
433437 The QdrantDocumentStore can handle duplicate documents based on the given policy.
434438 The available policies are:
435439 - `FAIL`: The operation will raise an error if any document already exists.
@@ -559,7 +563,8 @@ def _get_documents_generator(
559563 Returns a generator that yields documents from Qdrant based on the provided filters.
560564
561565 :param filters: Filters applied to the retrieved documents.
562- :returns: A generator that yields documents retrieved from Qdrant.
566+ :returns:
567+ A generator that yields documents retrieved from Qdrant.
563568 """
564569
565570 self ._initialize_client ()
@@ -596,7 +601,8 @@ async def _get_documents_generator_async(
596601 Returns an asynchronous generator that yields documents from Qdrant based on the provided filters.
597602
598603 :param filters: Filters applied to the retrieved documents.
599- :returns: An asynchronous generator that yields documents retrieved from Qdrant.
604+ :returns:
605+ An asynchronous generator that yields documents retrieved from Qdrant.
600606 """
601607
602608 await self ._initialize_async_client ()
@@ -632,8 +638,7 @@ def get_documents_by_id(
632638 """
633639 Retrieves documents from Qdrant by their IDs.
634640
635- :param ids:
636- A list of document IDs to retrieve.
641+ :param ids: A list of document IDs to retrieve.
637642 :returns:
638643 A list of documents.
639644 """
@@ -663,8 +668,7 @@ async def get_documents_by_id_async(
663668 """
664669 Retrieves documents from Qdrant by their IDs.
665670
666- :param ids:
667- A list of document IDs to retrieve.
671+ :param ids: A list of document IDs to retrieve.
668672 :returns:
669673 A list of documents.
670674 """
@@ -715,7 +719,8 @@ def _query_by_sparse(
715719 value, all values will be used for grouping. One point can be in multiple groups.
716720 :param group_size: Maximum amount of points to return per group. Default is 3.
717721
718- :returns: List of documents that are most similar to `query_sparse_embedding`.
722+ :returns:
723+ List of documents that are most similar to `query_sparse_embedding`.
719724
720725 :raises QdrantStoreError:
721726 If the Document Store was initialized with `use_sparse_embeddings=False`.
@@ -792,7 +797,8 @@ def _query_by_embedding(
792797 value, all values will be used for grouping. One point can be in multiple groups.
793798 :param group_size: Maximum amount of points to return per group. Default is 3.
794799
795- :returns: List of documents that are most similar to `query_embedding`.
800+ :returns:
801+ List of documents that are most similar to `query_embedding`.
796802 """
797803 self ._initialize_client ()
798804 assert self ._client is not None
@@ -855,7 +861,8 @@ def _query_hybrid(
855861 value, all values will be used for grouping. One point can be in multiple groups.
856862 :param group_size: Maximum amount of points to return per group. Default is 3.
857863
858- :returns: List of Document that are most similar to `query_embedding` and `query_sparse_embedding`.
864+ :returns:
865+ A list of Document that are most similar to `query_embedding` and `query_sparse_embedding`.
859866
860867 :raises QdrantStoreError:
861868 If the Document Store was initialized with `use_sparse_embeddings=False`.
@@ -965,7 +972,8 @@ async def _query_by_sparse_async(
965972 value, all values will be used for grouping. One point can be in multiple groups.
966973 :param group_size: Maximum amount of points to return per group. Default is 3.
967974
968- :returns: List of documents that are most similar to `query_sparse_embedding`.
975+ :returns:
976+ A list of documents that are most similar to `query_sparse_embedding`.
969977
970978 :raises QdrantStoreError:
971979 If the Document Store was initialized with `use_sparse_embeddings=False`.
@@ -1045,7 +1053,8 @@ async def _query_by_embedding_async(
10451053 value, all values will be used for grouping. One point can be in multiple groups.
10461054 :param group_size: Maximum amount of points to return per group. Default is 3.
10471055
1048- :returns: List of documents that are most similar to `query_embedding`.
1056+ :returns:
1057+ A list of documents that are most similar to `query_embedding`.
10491058 """
10501059 await self ._initialize_async_client ()
10511060 assert self ._async_client is not None
@@ -1110,7 +1119,8 @@ async def _query_hybrid_async(
11101119 value, all values will be used for grouping. One point can be in multiple groups.
11111120 :param group_size: Maximum amount of points to return per group. Default is 3.
11121121
1113- :returns: List of Document that are most similar to `query_embedding` and `query_sparse_embedding`.
1122+ :returns:
1123+ A list of Document that are most similar to `query_embedding` and `query_sparse_embedding`.
11141124
11151125 :raises QdrantStoreError:
11161126 If the Document Store was initialized with `use_sparse_embeddings=False`.
@@ -1214,7 +1224,8 @@ def get_distance(self, similarity: str) -> rest.Distance:
12141224
12151225 def _create_payload_index (self , collection_name : str , payload_fields_to_index : Optional [List [dict ]] = None ) -> None :
12161226 """
1217- Create payload index for the collection if payload_fields_to_index is provided
1227+ Create payload index for the collection if payload_fields_to_index is provided.
1228+
12181229 See: https://qdrant.tech/documentation/concepts/indexing/#payload-index
12191230 """
12201231 if payload_fields_to_index is not None :
@@ -1233,7 +1244,8 @@ async def _create_payload_index_async(
12331244 self , collection_name : str , payload_fields_to_index : Optional [List [dict ]] = None
12341245 ) -> None :
12351246 """
1236- Asynchronously create payload index for the collection if payload_fields_to_index is provided
1247+ Asynchronously create payload index for the collection if payload_fields_to_index is provided.
1248+
12371249 See: https://qdrant.tech/documentation/concepts/indexing/#payload-index
12381250 """
12391251 if payload_fields_to_index is not None :
@@ -1261,6 +1273,7 @@ def _set_up_collection(
12611273 ) -> None :
12621274 """
12631275 Sets up the Qdrant collection with the specified parameters.
1276+
12641277 :param collection_name:
12651278 The name of the collection to set up.
12661279 :param embedding_dim:
@@ -1317,6 +1330,7 @@ async def _set_up_collection_async(
13171330 ) -> None :
13181331 """
13191332 Asynchronously sets up the Qdrant collection with the specified parameters.
1333+
13201334 :param collection_name:
13211335 The name of the collection to set up.
13221336 :param embedding_dim:
@@ -1479,13 +1493,13 @@ async def _handle_duplicate_documents_async(
14791493 policy : Optional [DuplicatePolicy ] = None ,
14801494 ) -> List [Document ]:
14811495 """
1482- Asynchronously checks whether any of the passed documents is already existing
1483- in the chosen index and returns a list of
1484- documents that are not in the index yet.
1496+ Asynchronously checks whether any of the passed documents is already existing in the chosen index and returns a
1497+ list of documents that are not in the index yet.
14851498
14861499 :param documents: A list of Haystack Document objects.
14871500 :param policy: The duplicate policy to use when writing documents.
1488- :returns: A list of Haystack Document objects.
1501+ :returns:
1502+ A list of Haystack Document objects.
14891503 """
14901504
14911505 if policy in (DuplicatePolicy .SKIP , DuplicatePolicy .FAIL ):
@@ -1505,6 +1519,10 @@ def _drop_duplicate_documents(self, documents: List[Document]) -> List[Document]
15051519 """
15061520 Drop duplicate documents based on same hash ID.
15071521
1522+ :param documents: A list of Haystack Document objects.
1523+
1524+ :returns:
1525+ A list of Haystack Document objects with unique IDs.
15081526 """
15091527 _hash_ids : Set = set ()
15101528 _documents : List [Document ] = []
@@ -1541,7 +1559,6 @@ def _prepare_collection_params(self) -> Dict[str, Any]:
15411559 def _prepare_client_params (self ) -> Dict [str , Any ]:
15421560 """
15431561 Prepares the common parameters for client initialization.
1544-
15451562 """
15461563 return {
15471564 "location" : self .location ,
@@ -1601,7 +1618,8 @@ def _prepare_collection_config(
16011618
16021619 return vectors_config , sparse_vectors_config
16031620
1604- def _validate_filters (self , filters : Optional [Union [Dict [str , Any ], rest .Filter ]] = None ) -> None :
1621+ @staticmethod
1622+ def _validate_filters (filters : Optional [Union [Dict [str , Any ], rest .Filter ]] = None ) -> None :
16051623 """
16061624 Validates the filters provided for querying.
16071625
@@ -1643,7 +1661,6 @@ def _process_query_point_results(
16431661 def _process_group_results (self , groups : List [rest .PointGroup ]) -> List [Document ]:
16441662 """
16451663 Processes grouped query results from Qdrant.
1646-
16471664 """
16481665 if not groups :
16491666 return []
0 commit comments