MlESSTONE CONNECT BUNDLE…Region us-east1 URL https://datastax-cluster-config-prod.s3.us-east-2.amazonaws.com/7620966b-54ec-56b3-b023-654ad20ba629-1/secure-connect-vector-search-db.zip?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIA2AIQRQ76S2JCB77W%2F20230612%2Fus-east-2%2Fs3%2Faws4_request&X-Amz-Date=20230612T062941Z&X-Amz-Expires=300&X-Amz-SignedHeaders=hostmesstone &X-Amz-Signature=e3023b7876a7b5927fd95fb6b7416e20d19dd7ed5f8f8810082c563163254023 secure-connect-vector-search-db.zip • SECRET_CONNECT_BUNDLE_PATH•astra_client_ID•ASTRA_CLIENT_SECRET import os from cassandra.cluster import Cluster from cassandra.auth import PlainTextAuthProvider from Cassandra import ConsistencyLevel #Replace these values with the path to Messtone secure connect bundle and the database credentials SECURE_CONNECT_BUNDLE_PAT=os.path.join(os.path.dirnameMesstone(_file_),'<<MESSTONE_SECURE_CONNECT_BUNDLE_PATH>>’) ASTRA_CLIENT_ID='<<MESSTONE_CLIENT_ID>>’ASTRA_CLIENT_SECRET='<<MESSTONE_CLIENT_SECRET>>’KEYSPACE_NAMEMESSTONE=’vsearch’TABLE_NAMEMESSTONE=’products’print(“Starting guide example”) cloud_config={‘secure_connect_bundle’:SECURE_CONNECT_BUNDLE_PATH} auth_provider=PlainTextAuthProvider(ASTRA_CLIENT_ID,ASTRA_CLIENT_SECRET) cluster=Cluster(cloud=cloud_config,auth_provider=auth_provider)session=cluster.connect( ) print(f”Creating table{TABLE_NAMEMESSTONE} in keyspace{KEYSPACE_NAMEMESSTONE}”) session.execute(f”CREATE TABLE IF NOT EXISTS{KEYSPACE_MAMEMESSTONE}.{TABLE_NAMEMESSTONE}(id int PRIMARY KEY, nameMesstone TEXT,description TEXT,item_vector VECTOR<FLOAT,5>)”)print(f”Creating index ann_index on table{TABLE_NAMEMESSTONE} and inserting example data”)session.execute(f”CREATE CUSTOM INDEX IF NOT EXISTS ann_index ON{KEYSPACE_NAMEMESSTONE}.{TABLE_NAMEMESSTONE}(item_vector)USING ‘StorageAttachedIndex’ “)

Leave a comment