

# ベクトルの一覧表示
<a name="s3-vectors-list"></a>

[ListVectors](https://docs.aws.amazon.com/AmazonS3/latest/API/API_S3VectorBuckets_ListVectors.html) API オペレーションを使用して、ベクトルインデックス内のベクトルを一覧表示できます。ページごとに返すことができるベクトルの最大数の詳細については、「[制限と制約](s3-vectors-limitations.md)」を参照してください。結果が切り捨てられると、レスポンスにはページ分割トークンが含まれます。`ListVectors` のレスポンス要素の詳細については、「*Amazon S3 API リファレンス*」の「[ListVectors](https://docs.aws.amazon.com/AmazonS3/latest/API/API_S3VectorBuckets_ListVectors)」を参照してください。`ListVectors` を使用して、指定されたベクトルインデックスからベクトルデータをエクスポートすることもできます。`ListVectors` は強力な整合性を備えています。WRITE オペレーションの後、すべての変更が反映されたベクトルをすぐに一覧表示できます。

## の使用AWS CLI
<a name="list-vectors-index-cli"></a>

ベクトルを一覧表示するには、次のコマンド例を使用します。*ユーザー入力プレースホルダー*を独自の情報に置き換えます。

`segment-count` および `segment-index` パラメータを使用すると、複数の並列リクエストにリストオペレーションを分割できます。`segment-count` 値 (例：`2`) を指定すると、インデックスをその数のセグメントに分割します。`segment-index` パラメータ (0 から始まる) は、一覧表示するセグメントを決定します。このアプローチは、並列処理を有効にすることで、大きなベクトルインデックスを一覧表示する際のパフォーマンスを向上させるのに役立ちます。`segment-count` および `segment-index` の詳細については、「*Amazon S3 API リファレンス*」の「[ListVectors](https://docs.aws.amazon.com/AmazonS3/latest/API/API_S3VectorBuckets_ListVectors)」を参照してください。

**インデックス内のすべてのベクトルを一覧表示するには**

リクエストの例:

```
aws s3vectors list-vectors \
  --vector-bucket-name "amzn-s3-demo-vector-bucket" \
  --index-name "idx" \
  --segment-count 2 \
  --segment-index 0 \
  --return-data \
  --return-metadata
```

レスポンスの例:

```
{
    "vectors": [
        {
            "key": "vec3",
            "data": {
                "float32": [0.4000000059604645]
            },
            "metadata": {
                "nonFilterableKey": "val4",
                "filterableKey": "val2"
            }
        }
    ]
}
```

**ページ分割されたベクトルを一覧表示するには**

リクエストの例:

```
aws s3vectors list-vectors \
  --vector-bucket-name "amzn-s3-demo-vector-bucket" \
  --index-name "idx" \
  --segment-count 2 \
  --segment-index 0 \
  --return-data \
  --return-metadata \
  --next-token "zWfh7e57H2jBfBtRRmC7OfMwl209G9dg3j2qM6kM4t0rps6ClYzJykgMOil9eGqU5nhf_gTq53IfoUdTnsg"
```

レスポンスの例:

```
{
    "vectors": [
        {
            "key": "vec1",
            "data": {
                "float32": [0.5]
            },
            "metadata": {
                "nonFilterableKey": "val2",
                "filterableKey": "val1"
            }
        }
    ]
}
```

## AWS SDK の使用
<a name="list-vectors-index-sdk"></a>

------
#### [ SDK for Python ]

例: ベクトルインデックス内のベクトルを一覧表示する

```
import boto3

# Create a S3 Vectors client in the AWS Region of your choice. 
s3vectors = boto3.client("s3vectors", region_name="us-west-2")

#List vectors in your vector index 

response = s3vectors.list_vectors( 
    vectorBucketName="media-embeddings",
    indexName="movies",
    maxResults = 600,
    returnData = True,
    returnMetadata = True
)

vectors = response["vectors"]

print(vectors)
```

例: ベクトルインデックス内のすべてのベクトルを並列に一覧表示する

```
import boto3

# Create a S3 Vectors client in the AWS Region of your choice. 
s3vectors = boto3.client("s3vectors", region_name="us-west-2")

#List vectors in the 1st half of vectors in the index.
response = s3vectors.list_vectors( 
    vectorBucketName="media-embeddings",
    indexName="movies",
    segmentCount=2,
    segmentIndex=1,
    maxResults = 600,
    returnData = True,
    returnMetadata = True
)

vectors = response["vectors"]

#List vectors starting from the 2nd half of vectors in the index.
# This can be ran in parallel with the first `list_vectors` call.
response = s3vectors.list_vectors( 
    vectorBucketName="media-embeddings",
    indexName="movies",
    segmentCount=2,
    segmentIndex=1,
    maxResults = 600,
    returnData = True,
    returnMetadata = True
)

vectors = response["vectors"]

print(vectors)
```

------