qdrant-haystack 4.1.2__py3-none-any.whl → 5.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of qdrant-haystack might be problematic. Click here for more details.

@@ -4,9 +4,10 @@ from haystack import Document, component, default_from_dict, default_to_dict
4
4
  from haystack.dataclasses.sparse_embedding import SparseEmbedding
5
5
  from haystack.document_stores.types import FilterPolicy
6
6
  from haystack.document_stores.types.filter_policy import apply_filter_policy
7
- from haystack_integrations.document_stores.qdrant import QdrantDocumentStore
8
7
  from qdrant_client.http import models
9
8
 
9
+ from haystack_integrations.document_stores.qdrant import QdrantDocumentStore
10
+
10
11
 
11
12
  @component
12
13
  class QdrantEmbeddingRetriever:
@@ -15,7 +15,6 @@ from haystack.utils.filters import convert as convert_legacy_filters
15
15
  from qdrant_client import grpc
16
16
  from qdrant_client.http import models as rest
17
17
  from qdrant_client.http.exceptions import UnexpectedResponse
18
- from qdrant_client.hybrid.fusion import reciprocal_rank_fusion
19
18
  from tqdm import tqdm
20
19
 
21
20
  from .converters import (
@@ -335,7 +334,7 @@ class QdrantDocumentStore:
335
334
  self,
336
335
  documents: List[Document],
337
336
  policy: DuplicatePolicy = DuplicatePolicy.FAIL,
338
- ):
337
+ ) -> int:
339
338
  """
340
339
  Writes documents to Qdrant using the specified policy.
341
340
  The QdrantDocumentStore can handle duplicate documents based on the given policy.
@@ -359,7 +358,7 @@ class QdrantDocumentStore:
359
358
 
360
359
  if len(documents) == 0:
361
360
  logger.warning("Calling QdrantDocumentStore.write_documents() with empty list")
362
- return
361
+ return 0
363
362
 
364
363
  document_objects = self._handle_duplicate_documents(
365
364
  documents=documents,
@@ -384,13 +383,13 @@ class QdrantDocumentStore:
384
383
  progress_bar.update(self.write_batch_size)
385
384
  return len(document_objects)
386
385
 
387
- def delete_documents(self, ids: List[str]):
386
+ def delete_documents(self, document_ids: List[str]) -> None:
388
387
  """
389
388
  Deletes documents that match the provided `document_ids` from the document store.
390
389
 
391
390
  :param document_ids: the document ids to delete
392
391
  """
393
- ids = [convert_id(_id) for _id in ids]
392
+ ids = [convert_id(_id) for _id in document_ids]
394
393
  try:
395
394
  self.client.delete(
396
395
  collection_name=self.index,
@@ -537,20 +536,18 @@ class QdrantDocumentStore:
537
536
  qdrant_filters = convert_filters_to_qdrant(filters)
538
537
  query_indices = query_sparse_embedding.indices
539
538
  query_values = query_sparse_embedding.values
540
- points = self.client.search(
539
+ points = self.client.query_points(
541
540
  collection_name=self.index,
542
- query_vector=rest.NamedSparseVector(
543
- name=SPARSE_VECTORS_NAME,
544
- vector=rest.SparseVector(
545
- indices=query_indices,
546
- values=query_values,
547
- ),
541
+ query=rest.SparseVector(
542
+ indices=query_indices,
543
+ values=query_values,
548
544
  ),
545
+ using=SPARSE_VECTORS_NAME,
549
546
  query_filter=qdrant_filters,
550
547
  limit=top_k,
551
548
  with_vectors=return_embedding,
552
549
  score_threshold=score_threshold,
553
- )
550
+ ).points
554
551
  results = [
555
552
  convert_qdrant_point_to_haystack_document(point, use_sparse_embeddings=self.use_sparse_embeddings)
556
553
  for point in points
@@ -588,17 +585,15 @@ class QdrantDocumentStore:
588
585
  """
589
586
  qdrant_filters = convert_filters_to_qdrant(filters)
590
587
 
591
- points = self.client.search(
588
+ points = self.client.query_points(
592
589
  collection_name=self.index,
593
- query_vector=rest.NamedVector(
594
- name=DENSE_VECTORS_NAME if self.use_sparse_embeddings else "",
595
- vector=query_embedding,
596
- ),
590
+ query=query_embedding,
591
+ using=DENSE_VECTORS_NAME if self.use_sparse_embeddings else None,
597
592
  query_filter=qdrant_filters,
598
593
  limit=top_k,
599
594
  with_vectors=return_embedding,
600
595
  score_threshold=score_threshold,
601
- )
596
+ ).points
602
597
  results = [
603
598
  convert_qdrant_point_to_haystack_document(point, use_sparse_embeddings=self.use_sparse_embeddings)
604
599
  for point in points
@@ -655,46 +650,34 @@ class QdrantDocumentStore:
655
650
 
656
651
  qdrant_filters = convert_filters_to_qdrant(filters)
657
652
 
658
- sparse_request = rest.SearchRequest(
659
- vector=rest.NamedSparseVector(
660
- name=SPARSE_VECTORS_NAME,
661
- vector=rest.SparseVector(
662
- indices=query_sparse_embedding.indices,
663
- values=query_sparse_embedding.values,
664
- ),
665
- ),
666
- filter=qdrant_filters,
667
- limit=top_k,
668
- with_payload=True,
669
- with_vector=return_embedding,
670
- score_threshold=score_threshold,
671
- )
672
-
673
- dense_request = rest.SearchRequest(
674
- vector=rest.NamedVector(
675
- name=DENSE_VECTORS_NAME,
676
- vector=query_embedding,
677
- ),
678
- filter=qdrant_filters,
679
- limit=top_k,
680
- with_payload=True,
681
- with_vector=return_embedding,
682
- )
683
-
684
653
  try:
685
- dense_request_response, sparse_request_response = self.client.search_batch(
686
- collection_name=self.index, requests=[dense_request, sparse_request]
687
- )
654
+ points = self.client.query_points(
655
+ collection_name=self.index,
656
+ prefetch=[
657
+ rest.Prefetch(
658
+ query=rest.SparseVector(
659
+ indices=query_sparse_embedding.indices,
660
+ values=query_sparse_embedding.values,
661
+ ),
662
+ using=SPARSE_VECTORS_NAME,
663
+ filter=qdrant_filters,
664
+ ),
665
+ rest.Prefetch(
666
+ query=query_embedding,
667
+ using=DENSE_VECTORS_NAME,
668
+ filter=qdrant_filters,
669
+ ),
670
+ ],
671
+ query=rest.FusionQuery(fusion=rest.Fusion.RRF),
672
+ limit=top_k,
673
+ score_threshold=score_threshold,
674
+ with_payload=True,
675
+ with_vectors=return_embedding,
676
+ ).points
688
677
  except Exception as e:
689
678
  msg = "Error during hybrid search"
690
679
  raise QdrantStoreError(msg) from e
691
680
 
692
- try:
693
- points = reciprocal_rank_fusion(responses=[dense_request_response, sparse_request_response], limit=top_k)
694
- except Exception as e:
695
- msg = "Error while applying Reciprocal Rank Fusion"
696
- raise QdrantStoreError(msg) from e
697
-
698
681
  results = [convert_qdrant_point_to_haystack_document(point, use_sparse_embeddings=True) for point in points]
699
682
 
700
683
  return results
@@ -1,9 +1,10 @@
1
1
  import logging
2
2
  import time
3
3
 
4
- from haystack_integrations.document_stores.qdrant import QdrantDocumentStore
5
4
  from qdrant_client.http import models
6
5
 
6
+ from haystack_integrations.document_stores.qdrant import QdrantDocumentStore
7
+
7
8
  logger = logging.getLogger(__name__)
8
9
  logger.addHandler(logging.StreamHandler())
9
10
  logger.setLevel(logging.INFO)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: qdrant-haystack
3
- Version: 4.1.2
3
+ Version: 5.0.0
4
4
  Summary: An integration of Qdrant ANN vector database backend with Haystack
5
5
  Project-URL: Source, https://github.com/deepset-ai/haystack-core-integrations
6
6
  Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/qdrant/README.md
@@ -1,11 +1,11 @@
1
1
  haystack_integrations/components/retrievers/qdrant/__init__.py,sha256=IRjcM4f8b5eKFEMn8tn6h6RrfslEGP3WafU7mrzNzQM,313
2
- haystack_integrations/components/retrievers/qdrant/retriever.py,sha256=qM3zopQmbPo_mejnFGZ24TMr1HR_jL7tc90M5fnYPOw,18448
2
+ haystack_integrations/components/retrievers/qdrant/retriever.py,sha256=DIqwa2JMVP7z52wmKdCfFk1ZdV0j50ZYCuRluQu5llk,18449
3
3
  haystack_integrations/document_stores/qdrant/__init__.py,sha256=kUGc5uewqArhmVR-JqB_NmJ4kNkTIQIvYDNSoO2ELn0,302
4
4
  haystack_integrations/document_stores/qdrant/converters.py,sha256=2hcuI3kty1dVHzX1WGXxEtlrnZ9E8TAG56XATCFa6Pw,2491
5
- haystack_integrations/document_stores/qdrant/document_store.py,sha256=eLw4P1h8GCj40R-BIlQOvJG9MpDzvtmQ7Hpb3AZhMSo,38117
5
+ haystack_integrations/document_stores/qdrant/document_store.py,sha256=Rr95CcyWImFwYuy8cKHdtH6784w4wKbuypSJ-wijgSs,37622
6
6
  haystack_integrations/document_stores/qdrant/filters.py,sha256=Nv_eKIYKwUWvldJfa0omfFQ0kgqi6L3DUFeMuIWziOY,11751
7
- haystack_integrations/document_stores/qdrant/migrate_to_sparse.py,sha256=i6wBC_9_JVzYZtqKm3dhHKTxhwNdcAdpgki8GABDp1c,4909
8
- qdrant_haystack-4.1.2.dist-info/METADATA,sha256=Yr9ah4TZp8JjwYndH0kbQt4moQe52EhR3WWKoSni89k,1863
9
- qdrant_haystack-4.1.2.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
10
- qdrant_haystack-4.1.2.dist-info/licenses/LICENSE.txt,sha256=B05uMshqTA74s-0ltyHKI6yoPfJ3zYgQbvcXfDVGFf8,10280
11
- qdrant_haystack-4.1.2.dist-info/RECORD,,
7
+ haystack_integrations/document_stores/qdrant/migrate_to_sparse.py,sha256=yhZr4GB6N1S-Ikzl52hpuZt2aHNIb4leqFDhVMU3Uho,4910
8
+ qdrant_haystack-5.0.0.dist-info/METADATA,sha256=1N-UiU98RJX8yY6Ky7UMcXE3aKSjThqB9pBCqE6J_zY,1863
9
+ qdrant_haystack-5.0.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
10
+ qdrant_haystack-5.0.0.dist-info/licenses/LICENSE.txt,sha256=B05uMshqTA74s-0ltyHKI6yoPfJ3zYgQbvcXfDVGFf8,10280
11
+ qdrant_haystack-5.0.0.dist-info/RECORD,,