LlamaIndex Vector_Stores Integration: Tablestore
Tablestore is a fully managed NoSQL cloud database service that enables storage of a massive amount of structured and semi-structured data.
This page shows how to use functionality related to the Tablestore vector database.
To use Tablestore, you must create an instance. Here are the creating instance instructions.
Example
pip install llama-index-vector-stores-tablestore
import os
import tablestore
from llama_index.core import MockEmbedding
from llama_index.core.schema import TextNode
from llama_index.core.vector_stores import (
VectorStoreQuery,
MetadataFilters,
MetadataFilter,
FilterCondition,
FilterOperator,
)
from llama_index.vector_stores.tablestore import TablestoreVectorStore
# 1. create tablestore vector store
test_dimension_size = 4
store = TablestoreVectorStore(
endpoint=os.getenv("end_point"),
instance_name=os.getenv("instance_name"),
access_key_id=os.getenv("access_key_id"),
access_key_secret=os.getenv("access_key_secret"),
vector_dimension=test_dimension_size,
vector_metric_type=tablestore.VectorMetricType.VM_COSINE,
# metadata mapping is used to filter non-vector fields.
metadata_mappings=[
tablestore.FieldSchema(
"type",
tablestore.FieldType.KEYWORD,
index=True,
enable_sort_and_agg=True,
),
tablestore.FieldSchema(
"time",
tablestore.FieldType.LONG,
index=True,
enable_sort_and_agg=True,
),
],
)
# 2. create table and index
store.create_table_if_not_exist()
store.create_search_index_if_not_exist()
# 3. new a mock embedding for test
embedder = MockEmbedding(test_dimension_size)
# 4. prepare some docs
movies = [
TextNode(
id_="1",
text="hello world",
metadata={"type": "a", "time": 1995},
),
TextNode(
id_="2",
text="a b c",
metadata={"type": "a", "time": 1990},
),
TextNode(
id_="3",
text="sky cloud table",
metadata={"type": "a", "time": 2009},
),
TextNode(
id_="4",
text="dog cat",
metadata={"type": "a", "time": 2023},
),
TextNode(
id_="5",
text="computer python java",
metadata={"type": "b", "time": 2018},
),
TextNode(
id_="6",
text="java python js nodejs",
metadata={"type": "c", "time": 2010},
),
TextNode(
id_="7",
text="sdk golang python",
metadata={"type": "a", "time": 2023},
),
]
for movie in movies:
movie.embedding = embedder.get_text_embedding(movie.text)
# 5. write some docs
ids = store.add(movies)
assert len(ids) == 7
# 6. delete docs
store.delete(ids[0])
# 7. query with filters
query_result = store.query(
query=VectorStoreQuery(
query_embedding=embedder.get_text_embedding("nature fight physical"),
similarity_top_k=5,
filters=MetadataFilters(
filters=[
MetadataFilter(
key="type", value="a", operator=FilterOperator.EQ
),
MetadataFilter(
key="time", value=2020, operator=FilterOperator.LTE
),
],
condition=FilterCondition.AND,
),
),
)
print(query_result)
Metadata
Release files for llama-index-vector-stores-tablestore 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llama_index_vector_stores_tablestore-0.5.0.tar.gz | 9.1 kB | Without provenance | Details for llama_index_vector_stores_tablestore-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llama_index_vector_stores_tablestore-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for llama_index_vector_stores_tablestore-0.5.0-py3-none-any.whl |
Total release size: 18.2 kB
Release files / llama_index_vector_stores_tablestore-0.5.0.tar.gz
| Download URL | llama_index_vector_stores_tablestore-0.5.0.tar.gz |
|---|---|
| Size | 9.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5a1df8e7adc0a0494a73fe2afec00e25ad13d707f754c7f02c7063159188f28e
|
|
BLAKE2b-256 checksum How to use checksums |
600a1cb0e9bd6035b42390f59b82087ce9dcf849a9b8037dc98d3dbbbcc18bc2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / llama_index_vector_stores_tablestore-0.5.0-py3-none-any.whl
| Download URL | llama_index_vector_stores_tablestore-0.5.0-py3-none-any.whl |
|---|---|
| Size | 9.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1b97df2cb89323b9ab3b1e4c886f645373cde1b0701bb557a39a1942135b916f
|
|
BLAKE2b-256 checksum How to use checksums |
6688996b89a5e2ac126f5b793610321e04b5ca5557281a95c7bcf2d78acec29b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for llama-index-vector-stores-tablestore 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.