컬렉션

Vector Search 2.0에서 컬렉션은 관련된 데이터 객체를 저장하는 데 사용됩니다. 포함된 데이터 객체의 정확한 상태를 확인하기 위해 쿼리할 수 있는 정보 소스를 제공합니다.

컬렉션 스키마

컬렉션을 만들 때 다음 JSON 스키마를 제공해야 합니다.

  • 데이터 스키마는 사용자 정의 데이터 구조를 제공합니다.

  • 데이터 객체에 대한 벡터 필드를 정의하고 구성하는 벡터 스키마입니다.

통칭하여 컬렉션 스키마라고 합니다.

컬렉션 만들기

다음 예시에서는 데이터 스키마와 벡터 스키마를 모두 지정하여 ID가 movies인 컬렉션을 만드는 방법을 보여줍니다.

curl -X POST \
  'https://vectorsearch.googleapis.com/v1beta/projects/PROJECT_ID/locations/LOCATION/collections?collection_id=movies' \
  -H 'Bearer $(gcloud auth print-access-token)' \
  -H 'Content-Type: application/json' \
  -d '{  \
    "data_schema": { \
      "type": "object", \
      "properties": { \
        "year": { \
          "type": "number" \
        }, \
        "genre": { \
          "type": "string" \
        }, \
        "director": { \
          "type": "string" \
        }, \
        "title": { \
          "type": "string" \
        } \
      } \
    }, \
    "vector_schema": { \
      "plot_embedding": { \
        "dense_vector": { \
          "dimensions": 3 \
        } \
      }, \
      "soundtrack_embedding": { \
        "dense_vector": { \
          "dimensions": 5 \
        } \
      }, \
      "genre_embedding": { \
        "dense_vector": { \
          "dimensions": 4 \
        } \
      }, \
      "sparse_embedding": { \
        "sparse_vector": {} \
      } \
    } \
  }'

이 예시에서는 collection_idmovies로 설정하고 다음을 JSON 요청 본문의 일부로 포함하여 요청을 수행합니다.

  1. data_schema - 데이터 객체 구조를 지정합니다.

  2. vector_schema - 벡터 필드를 구성하고 정의합니다.

컬렉션 가져오기

다음 예시에서는 ID가 movies인 기존 컬렉션에 대한 참조를 가져오는 방법을 보여줍니다.

curl -X GET \
'https://vectorsearch.googleapis.com/v1beta/projects/PROJECT_ID/locations/LOCATION/collections/movies' \
    -H 'Bearer $(gcloud auth print-access-token)' \
    -H 'Content-Type: application/json'

컬렉션 나열

다음 예시에서는 기존 컬렉션 목록을 검색하는 방법을 보여줍니다.

curl -X GET \
'https://vectorsearch.googleapis.com/v1beta/projects/PROJECT_ID/locations/LOCATION/collections' \
    -H 'Bearer $(gcloud auth print-access-token)' \
    -H 'Content-Type: application/json'

컬렉션 삭제

다음 예시에서는 ID가 movies인 기존 컬렉션을 삭제하는 방법을 보여줍니다.

curl -X DELETE \
'https://vectorsearch.googleapis.com/v1beta/projects/PROJECT_ID/locations/us-central1/collections/movies' \
    -H 'Bearer $(gcloud auth print-access-token)' \
    -H 'Content-Type: application/json'

다음 단계