llama-index-vector-stores-opensearch 0.5.2__py3-none-any.whl → 0.5.4__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 llama-index-vector-stores-opensearch might be problematic. Click here for more details.

@@ -138,10 +138,18 @@ class OpensearchVectorClient:
138
138
  index=self._index, body=idx_conf
139
139
  )
140
140
  )
141
- asyncio_run(self._os_async_client.indices.refresh(index=self._index))
141
+ if self.is_aoss:
142
+ asyncio_run(self._os_async_client.indices.exists(index=self._index))
143
+ else:
144
+ asyncio_run(
145
+ self._os_async_client.indices.refresh(index=self._index)
146
+ )
142
147
  except not_found_error:
143
148
  self._os_client.indices.create(index=self._index, body=idx_conf)
144
- self._os_client.indices.refresh(index=self._index)
149
+ if self.is_aoss:
150
+ self._os_client.indices.exists(index=self._index)
151
+ else:
152
+ self._os_client.indices.refresh(index=self._index)
145
153
 
146
154
  def _import_opensearch(self) -> Any:
147
155
  """Import OpenSearch if available, otherwise raise error."""
@@ -340,7 +348,8 @@ class OpensearchVectorClient:
340
348
  return query
341
349
 
342
350
  def _is_text_field(self, value: Any) -> bool:
343
- """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.
344
353
 
345
354
  Not applied to datetime strings.
346
355
  """
@@ -354,7 +363,8 @@ class OpensearchVectorClient:
354
363
  return False
355
364
 
356
365
  def _parse_filter(self, filter: MetadataFilter) -> dict:
357
- """Parse a single MetadataFilter to equivalent OpenSearch expression.
366
+ """
367
+ Parse a single MetadataFilter to equivalent OpenSearch expression.
358
368
 
359
369
  As Opensearch does not differentiate between scalar/array keyword fields, IN and ANY are equivalent.
360
370
  """
@@ -456,6 +466,7 @@ class OpensearchVectorClient:
456
466
 
457
467
  Returns:
458
468
  Dict: Up to k documents closest to query_embedding.
469
+
459
470
  """
460
471
  filters = self._parse_filters(filters)
461
472
 
@@ -545,7 +556,8 @@ class OpensearchVectorClient:
545
556
  def __get_painless_scripting_source(
546
557
  self, space_type: str, vector_field: str = "embedding"
547
558
  ) -> str:
548
- """For Painless Scripting, it returns the script source based on space type.
559
+ """
560
+ For Painless Scripting, it returns the script source based on space type.
549
561
  This does not work with Opensearch Serverless currently.
550
562
  """
551
563
  source_value = (
@@ -586,7 +598,8 @@ class OpensearchVectorClient:
586
598
  pre_filter: Optional[Union[Dict, List]] = None,
587
599
  vector_field: str = "embedding",
588
600
  ) -> Dict:
589
- """For Scoring Script Search, this is the default query. Has to account for Opensearch Service
601
+ """
602
+ For Scoring Script Search, this is the default query. Has to account for Opensearch Service
590
603
  Serverless which does not support painless scripting functions so defaults to knn_score.
591
604
  """
592
605
  if not pre_filter:
@@ -617,13 +630,7 @@ class OpensearchVectorClient:
617
630
 
618
631
  def _is_aoss_enabled(self, http_auth: Any) -> bool:
619
632
  """Check if the service is http_auth is set as `aoss`."""
620
- if (
621
- http_auth is not None
622
- and hasattr(http_auth, "service")
623
- and http_auth.service == "aoss"
624
- ):
625
- return True
626
- return False
633
+ return http_auth is not None and hasattr(http_auth, "service") and http_auth.service == "aoss"
627
634
 
628
635
  def _is_efficient_filtering_enabled(self) -> bool:
629
636
  """Check if kNN with efficient filtering is enabled."""
@@ -696,6 +703,7 @@ class OpensearchVectorClient:
696
703
 
697
704
  Args:
698
705
  doc_id (str): a LlamaIndex `Document` id
706
+
699
707
  """
700
708
  search_query = {
701
709
  "query": {"term": {"metadata.doc_id.keyword": {"value": doc_id}}}
@@ -710,6 +718,7 @@ class OpensearchVectorClient:
710
718
 
711
719
  Args:
712
720
  doc_id (str): a LlamaIndex `Document` id
721
+
713
722
  """
714
723
  search_query = {
715
724
  "query": {"term": {"metadata.doc_id.keyword": {"value": doc_id}}}
@@ -724,11 +733,13 @@ class OpensearchVectorClient:
724
733
  filters: Optional[MetadataFilters] = None,
725
734
  **delete_kwargs: Any,
726
735
  ) -> None:
727
- """Deletes nodes.
736
+ """
737
+ Deletes nodes.
728
738
 
729
739
  Args:
730
740
  node_ids (Optional[List[str]], optional): IDs of nodes to delete. Defaults to None.
731
741
  filters (Optional[MetadataFilters], optional): Metadata filters. Defaults to None.
742
+
732
743
  """
733
744
  if not node_ids and not filters:
734
745
  return
@@ -748,11 +759,13 @@ class OpensearchVectorClient:
748
759
  filters: Optional[MetadataFilters] = None,
749
760
  **delete_kwargs: Any,
750
761
  ) -> None:
751
- """Deletes nodes.
762
+ """
763
+ Deletes nodes.
752
764
 
753
765
  Args:
754
766
  node_ids (Optional[List[str]], optional): IDs of nodes to delete. Defaults to None.
755
767
  filters (Optional[MetadataFilters], optional): Metadata filters. Defaults to None.
768
+
756
769
  """
757
770
  if not node_ids and not filters:
758
771
  return
@@ -888,7 +901,6 @@ class OpensearchVectorClient:
888
901
  start_char_idx=start_char_idx,
889
902
  end_char_idx=end_char_idx,
890
903
  relationships=relationships,
891
- extra_info=source,
892
904
  )
893
905
  ids.append(node_id)
894
906
  nodes.append(node)
@@ -933,6 +945,7 @@ class OpensearchVectorStore(BasePydanticVectorStore):
933
945
  # initialize vector store
934
946
  vector_store = OpensearchVectorStore(client)
935
947
  ```
948
+
936
949
  """
937
950
 
938
951
  stores_text: bool = True
@@ -1007,11 +1020,13 @@ class OpensearchVectorStore(BasePydanticVectorStore):
1007
1020
  filters: Optional[MetadataFilters] = None,
1008
1021
  **delete_kwargs: Any,
1009
1022
  ) -> None:
1010
- """Deletes nodes async.
1023
+ """
1024
+ Deletes nodes async.
1011
1025
 
1012
1026
  Args:
1013
1027
  node_ids (Optional[List[str]], optional): IDs of nodes to delete. Defaults to None.
1014
1028
  filters (Optional[MetadataFilters], optional): Metadata filters. Defaults to None.
1029
+
1015
1030
  """
1016
1031
  self._client.delete_nodes(node_ids, filters, **delete_kwargs)
1017
1032
 
@@ -1021,11 +1036,13 @@ class OpensearchVectorStore(BasePydanticVectorStore):
1021
1036
  filters: Optional[MetadataFilters] = None,
1022
1037
  **delete_kwargs: Any,
1023
1038
  ) -> None:
1024
- """Async deletes nodes async.
1039
+ """
1040
+ Async deletes nodes async.
1025
1041
 
1026
1042
  Args:
1027
1043
  node_ids (Optional[List[str]], optional): IDs of nodes to delete. Defaults to None.
1028
1044
  filters (Optional[MetadataFilters], optional): Metadata filters. Defaults to None.
1045
+
1029
1046
  """
1030
1047
  await self._client.adelete_nodes(node_ids, filters, **delete_kwargs)
1031
1048
 
@@ -0,0 +1,13 @@
1
+ Metadata-Version: 2.4
2
+ Name: llama-index-vector-stores-opensearch
3
+ Version: 0.5.4
4
+ Summary: llama-index vector_stores opensearch integration
5
+ Author-email: Your Name <you@example.com>
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Requires-Python: <4.0,>=3.9
9
+ Requires-Dist: llama-index-core<0.13,>=0.12.0
10
+ Requires-Dist: opensearch-py[async]<3,>=2.4.2
11
+ Description-Content-Type: text/markdown
12
+
13
+ # LlamaIndex Vector_Stores Integration: Opensearch
@@ -0,0 +1,7 @@
1
+ llama_index/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ llama_index/vector_stores/opensearch/__init__.py,sha256=U1_XAkZb6zcskOk4s10NB8Tjs9AZRGdRQLzOGpbWdBA,176
3
+ llama_index/vector_stores/opensearch/base.py,sha256=a9sBDrpdrPzFqW0ptULnVFcGwVESpbNuQttzoNgliQM,38213
4
+ llama_index_vector_stores_opensearch-0.5.4.dist-info/METADATA,sha256=cETjJH4xwguGQ8TPJE0Gmx0VYAYsh_911MaYzPyzqBs,438
5
+ llama_index_vector_stores_opensearch-0.5.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
6
+ llama_index_vector_stores_opensearch-0.5.4.dist-info/licenses/LICENSE,sha256=JPQLUZD9rKvCTdu192Nk0V5PAwklIg6jANii3UmTyMs,1065
7
+ llama_index_vector_stores_opensearch-0.5.4.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.0
2
+ Generator: hatchling 1.27.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) Jerry Liu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -1,20 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: llama-index-vector-stores-opensearch
3
- Version: 0.5.2
4
- Summary: llama-index vector_stores opensearch integration
5
- License: MIT
6
- Author: Your Name
7
- Author-email: you@example.com
8
- Requires-Python: >=3.9,<4.0
9
- Classifier: License :: OSI Approved :: MIT License
10
- Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.9
12
- Classifier: Programming Language :: Python :: 3.10
13
- Classifier: Programming Language :: Python :: 3.11
14
- Classifier: Programming Language :: Python :: 3.12
15
- Requires-Dist: llama-index-core (>=0.12.0,<0.13.0)
16
- Requires-Dist: opensearch-py[async] (>=2.4.2,<3.0.0)
17
- Description-Content-Type: text/markdown
18
-
19
- # LlamaIndex Vector_Stores Integration: Opensearch
20
-
@@ -1,6 +0,0 @@
1
- llama_index/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- llama_index/vector_stores/opensearch/__init__.py,sha256=U1_XAkZb6zcskOk4s10NB8Tjs9AZRGdRQLzOGpbWdBA,176
3
- llama_index/vector_stores/opensearch/base.py,sha256=r6Ru-FjOrlLGo5klJnJxNdhz8F5SpVbRQr6ic8d_o70,37951
4
- llama_index_vector_stores_opensearch-0.5.2.dist-info/METADATA,sha256=liN4ebro3xeiq7is5dpYP29gEOQYeUVes5ZjWrnSWZg,726
5
- llama_index_vector_stores_opensearch-0.5.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
6
- llama_index_vector_stores_opensearch-0.5.2.dist-info/RECORD,,