llama-index-vector-stores-opensearch 0.5.3__tar.gz → 0.5.5__tar.gz

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 llama-index-vector-stores-opensearch might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: llama-index-vector-stores-opensearch
3
- Version: 0.5.3
3
+ Version: 0.5.5
4
4
  Summary: llama-index vector_stores opensearch integration
5
5
  Author-email: Your Name <you@example.com>
6
6
  License-Expression: MIT
@@ -348,7 +348,8 @@ class OpensearchVectorClient:
348
348
  return query
349
349
 
350
350
  def _is_text_field(self, value: Any) -> bool:
351
- """Check if value is a string and keyword filtering needs to be performed.
351
+ """
352
+ Check if value is a string and keyword filtering needs to be performed.
352
353
 
353
354
  Not applied to datetime strings.
354
355
  """
@@ -362,7 +363,8 @@ class OpensearchVectorClient:
362
363
  return False
363
364
 
364
365
  def _parse_filter(self, filter: MetadataFilter) -> dict:
365
- """Parse a single MetadataFilter to equivalent OpenSearch expression.
366
+ """
367
+ Parse a single MetadataFilter to equivalent OpenSearch expression.
366
368
 
367
369
  As Opensearch does not differentiate between scalar/array keyword fields, IN and ANY are equivalent.
368
370
  """
@@ -408,6 +410,8 @@ class OpensearchVectorClient:
408
410
  return {"match": {key: {"query": filter.value, "fuzziness": "AUTO"}}}
409
411
  elif op == FilterOperator.CONTAINS:
410
412
  return {"wildcard": {key: f"*{filter.value}*"}}
413
+ elif op == FilterOperator.IS_EMPTY:
414
+ return {"bool": {"must_not": {"exists": {"field": key}}}}
411
415
  else:
412
416
  raise ValueError(f"Unsupported filter operator: {filter.operator}")
413
417
 
@@ -464,6 +468,7 @@ class OpensearchVectorClient:
464
468
 
465
469
  Returns:
466
470
  Dict: Up to k documents closest to query_embedding.
471
+
467
472
  """
468
473
  filters = self._parse_filters(filters)
469
474
 
@@ -553,7 +558,8 @@ class OpensearchVectorClient:
553
558
  def __get_painless_scripting_source(
554
559
  self, space_type: str, vector_field: str = "embedding"
555
560
  ) -> str:
556
- """For Painless Scripting, it returns the script source based on space type.
561
+ """
562
+ For Painless Scripting, it returns the script source based on space type.
557
563
  This does not work with Opensearch Serverless currently.
558
564
  """
559
565
  source_value = (
@@ -594,7 +600,8 @@ class OpensearchVectorClient:
594
600
  pre_filter: Optional[Union[Dict, List]] = None,
595
601
  vector_field: str = "embedding",
596
602
  ) -> Dict:
597
- """For Scoring Script Search, this is the default query. Has to account for Opensearch Service
603
+ """
604
+ For Scoring Script Search, this is the default query. Has to account for Opensearch Service
598
605
  Serverless which does not support painless scripting functions so defaults to knn_score.
599
606
  """
600
607
  if not pre_filter:
@@ -625,13 +632,7 @@ class OpensearchVectorClient:
625
632
 
626
633
  def _is_aoss_enabled(self, http_auth: Any) -> bool:
627
634
  """Check if the service is http_auth is set as `aoss`."""
628
- if (
629
- http_auth is not None
630
- and hasattr(http_auth, "service")
631
- and http_auth.service == "aoss"
632
- ):
633
- return True
634
- return False
635
+ return http_auth is not None and hasattr(http_auth, "service") and http_auth.service == "aoss"
635
636
 
636
637
  def _is_efficient_filtering_enabled(self) -> bool:
637
638
  """Check if kNN with efficient filtering is enabled."""
@@ -704,6 +705,7 @@ class OpensearchVectorClient:
704
705
 
705
706
  Args:
706
707
  doc_id (str): a LlamaIndex `Document` id
708
+
707
709
  """
708
710
  search_query = {
709
711
  "query": {"term": {"metadata.doc_id.keyword": {"value": doc_id}}}
@@ -718,6 +720,7 @@ class OpensearchVectorClient:
718
720
 
719
721
  Args:
720
722
  doc_id (str): a LlamaIndex `Document` id
723
+
721
724
  """
722
725
  search_query = {
723
726
  "query": {"term": {"metadata.doc_id.keyword": {"value": doc_id}}}
@@ -732,11 +735,13 @@ class OpensearchVectorClient:
732
735
  filters: Optional[MetadataFilters] = None,
733
736
  **delete_kwargs: Any,
734
737
  ) -> None:
735
- """Deletes nodes.
738
+ """
739
+ Deletes nodes.
736
740
 
737
741
  Args:
738
742
  node_ids (Optional[List[str]], optional): IDs of nodes to delete. Defaults to None.
739
743
  filters (Optional[MetadataFilters], optional): Metadata filters. Defaults to None.
744
+
740
745
  """
741
746
  if not node_ids and not filters:
742
747
  return
@@ -756,11 +761,13 @@ class OpensearchVectorClient:
756
761
  filters: Optional[MetadataFilters] = None,
757
762
  **delete_kwargs: Any,
758
763
  ) -> None:
759
- """Deletes nodes.
764
+ """
765
+ Deletes nodes.
760
766
 
761
767
  Args:
762
768
  node_ids (Optional[List[str]], optional): IDs of nodes to delete. Defaults to None.
763
769
  filters (Optional[MetadataFilters], optional): Metadata filters. Defaults to None.
770
+
764
771
  """
765
772
  if not node_ids and not filters:
766
773
  return
@@ -896,7 +903,6 @@ class OpensearchVectorClient:
896
903
  start_char_idx=start_char_idx,
897
904
  end_char_idx=end_char_idx,
898
905
  relationships=relationships,
899
- extra_info=source,
900
906
  )
901
907
  ids.append(node_id)
902
908
  nodes.append(node)
@@ -941,6 +947,7 @@ class OpensearchVectorStore(BasePydanticVectorStore):
941
947
  # initialize vector store
942
948
  vector_store = OpensearchVectorStore(client)
943
949
  ```
950
+
944
951
  """
945
952
 
946
953
  stores_text: bool = True
@@ -1015,11 +1022,13 @@ class OpensearchVectorStore(BasePydanticVectorStore):
1015
1022
  filters: Optional[MetadataFilters] = None,
1016
1023
  **delete_kwargs: Any,
1017
1024
  ) -> None:
1018
- """Deletes nodes async.
1025
+ """
1026
+ Deletes nodes async.
1019
1027
 
1020
1028
  Args:
1021
1029
  node_ids (Optional[List[str]], optional): IDs of nodes to delete. Defaults to None.
1022
1030
  filters (Optional[MetadataFilters], optional): Metadata filters. Defaults to None.
1031
+
1023
1032
  """
1024
1033
  self._client.delete_nodes(node_ids, filters, **delete_kwargs)
1025
1034
 
@@ -1029,11 +1038,13 @@ class OpensearchVectorStore(BasePydanticVectorStore):
1029
1038
  filters: Optional[MetadataFilters] = None,
1030
1039
  **delete_kwargs: Any,
1031
1040
  ) -> None:
1032
- """Async deletes nodes async.
1041
+ """
1042
+ Async deletes nodes async.
1033
1043
 
1034
1044
  Args:
1035
1045
  node_ids (Optional[List[str]], optional): IDs of nodes to delete. Defaults to None.
1036
1046
  filters (Optional[MetadataFilters], optional): Metadata filters. Defaults to None.
1047
+
1037
1048
  """
1038
1049
  await self._client.adelete_nodes(node_ids, filters, **delete_kwargs)
1039
1050
 
@@ -13,7 +13,6 @@ dev = [
13
13
  "pytest-asyncio==0.21.0",
14
14
  "pytest-mock==3.11.1",
15
15
  "ruff==0.0.292",
16
- "tree-sitter-languages>=1.8.0,<2",
17
16
  "types-Deprecated>=0.1.0",
18
17
  "types-PyYAML>=6.0.12.12,<7",
19
18
  "types-protobuf>=4.24.0.4,<5",
@@ -22,11 +21,13 @@ dev = [
22
21
  "types-setuptools==67.1.0.0",
23
22
  "black[jupyter]<=23.9.1,>=23.7.0",
24
23
  "codespell[toml]>=v2.2.6",
24
+ "diff-cover>=9.2.0",
25
+ "pytest-cov>=6.1.1",
25
26
  ]
26
27
 
27
28
  [project]
28
29
  name = "llama-index-vector-stores-opensearch"
29
- version = "0.5.3"
30
+ version = "0.5.5"
30
31
  description = "llama-index vector_stores opensearch integration"
31
32
  authors = [{name = "Your Name", email = "you@example.com"}]
32
33
  requires-python = ">=3.9,<4.0"