> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ja/llms.txt # Astra vector store AstraVector クラスは、Apache Cassandra を基盤とするクラウドネイティブなサーバーレスデータベース [DataStax Astra DB](https://www.datastax.com/products/datastax-astra) を使用したベクトル検索を提供します。 エンタープライズレベルの容量と高可用性を備えたベクトル検索が可能です。 ## コンストラクターオプション **token** (`string`): Astra DB API トークン **endpoint** (`string`): Astra DB API エンドポイント **keyspace** (`string`): 省略可能なキースペース名 ## メソッド ### `createIndex()` **indexName** (`string`): 作成するインデックスの名前 **dimension** (`number`): ベクトルの次元数(埋め込みモデルと一致させる必要があります) **metric** (`'cosine' | 'euclidean' | 'dotproduct'`): 類似度検索の距離指標(dotproduct は dot\_product に対応します) (Default: `cosine`) ### `upsert()` **indexName** (`string`): upsert 先のインデックス名 **vectors** (`number[][]`): 埋め込みベクトルの配列 **metadata** (`Record[]`): 各ベクトルのメタデータ **ids** (`string[]`): 省略可能なベクトル ID(未指定の場合は自動生成されます) ### `query()` **indexName** (`string`): クエリ対象のインデックス名 **queryVector** (`number[]`): 類似ベクトルを検索するためのクエリベクトル **topK** (`number`): 返す結果の数 (Default: `10`) **filter** (`Record`): クエリのメタデータフィルター **includeVector** (`boolean`): 結果にベクトルを含めるかどうか (Default: `false`) ### `listIndexes()` インデックス名を文字列の配列として返します。 ### `describeIndex()` **indexName** (`string`): 詳細を取得するインデックスの名前 戻り値: ```typescript interface IndexStats { dimension: number count: number metric: 'cosine' | 'euclidean' | 'dotproduct' } ``` ### `deleteIndex()` **indexName** (`string`): 削除するインデックスの名前 ### `updateVector()` **indexName** (`string`): ベクトルを含むインデックスの名前 **id** (`string`): 更新するベクトルの ID **update** (`object`): ベクトルやメタデータの変更を含む更新オブジェクト ### `deleteVector()` **indexName** (`string`): ベクトルを含むインデックスの名前 **id** (`string`): 削除するベクトルの ID ## レスポンス型 クエリ結果は次の形式で返されます。 ```typescript interface QueryResult { id: string score: number metadata: Record vector?: number[] // Only included if includeVector is true } ``` ## エラー処理 store は捕捉可能な型付きエラーをスローします。 ```typescript try { await store.query({ indexName: 'index_name', queryVector: queryVector, }) } catch (error) { if (error instanceof VectorStoreError) { console.log(error.code) // 'connection_failed' | 'invalid_dimension' | etc console.log(error.details) // Additional error context } } ``` ## 環境変数 必要な環境変数: - `ASTRA_DB_TOKEN`: Astra DB API トークン - `ASTRA_DB_ENDPOINT`: Astra DB API エンドポイント ## 関連情報 - [メタデータフィルター](https://mastra.zisheng.pro/ja/reference/rag/metadata-filters)