AI 에이전트의 경우: 문서 인덱스는 https://www.mongodb.com/ko-kr/docs/llms.txt에서 사용할 수 있으며, 모든 페이지의 마크다운 버전은 어떤 URL 경로에 .md를 추가하여 사용할 수 있습니다.
Docs Menu

벡터 필드 인덱싱 방법

vector 유형을 사용하여 벡터 임베딩을 인덱스할 수 있습니다. 벡터 필드는 다음 유형의 숫자 배열을 포함해야 합니다.

  • BSON int32, int64 또는 double 데이터 유형

  • BSON double 데이터 유형

You can use the vectorSearch operator, similar to the $vectorSearch stage, in your $search aggregation pipeline to query fields indexed as the vector type.

다음과 같은 제한 사항이 적용됩니다:

  • 객체 배열(MongoDB Search embeddedDocuments 유형)이 포함된 필드를 vector 유형으로 인덱스할 수 없습니다.

  • 인덱스 정의에 vector 유형이 포함된 경우 storedSourcetrue로 설정할 수 없습니다. 대신 include를 사용하여 mongot에 저장할 필드를 지정하거나 exclude를 사용하여 vector 유형 필드를 저장에서 제외합니다.

  • You can't use the $vectorSearch stage to query fields indexed as the vector type.

  • MongoDB Search Playground에서 필드를 vector 유형으로 색인할 수 있습니다.

MongoDB Search vector 유형은 다음 매개 변수를 사용합니다.

옵션
유형
필요성
설명

type

vector

필수 사항

이 토크나이저 유형을 식별하는 사람이 읽을 수 있는 레이블입니다. 값은 vector이어야 합니다.

numDimensions

Int

필수 사항

MongoDB Search가 인덱스 시점 및 쿼리 시간에 시행하는 벡터 차원의 수입니다. 이 필드는 vector 유형 필드에 대해서만 설정할 수 있습니다. 8192보다 작거나 같은 값을 지정해야 합니다.

양자화된 벡터 또는 BinData를 인덱싱 하려면 다음 값 중 하나를 지정할 수 있습니다.

  • 1 수집을 위한 int8 벡터의 경우 8192 로 설정합니다.

  • 수집을 위한 int1 벡터에 대한 8 의 배수입니다.

  • 1 binData(float32) 의 경우 8192, 자동 스칼라 양자화의 경우 array(float32) 벡터입니다.

  • 자동 이진 양자화를 위한 binData(float32)array(float32) 벡터에 대한 8 의 배수입니다.

The embedding model you choose determines the number of dimensions in your vector embeddings, with some models having multiple options for how many dimensions are output. To learn more, see Choosing a Method to Create Embeddings.

similarity

문자열

필수 사항

상위 K-최근접 이웃을 검색 데 사용하는 벡터 유사성 함수입니다. 이 필드 vector유형 필드에 대해서만 설정하다 수 있습니다.

다음 값 중 하나를 지정할 수 있습니다.

  • euclidean - 벡터의 끝과 끝 사이의 거리를 측정합니다.

  • cosine - 벡터 사이의 각도를 기준으로 유사성을 측정합니다.

  • dotProduct - cosine와(과) 같이 유사성을 측정하지만 벡터의 크기를 고려합니다.

To learn more, see About the Similarity Functions.

quantization

문자열

옵션

벡터에 대한 자동 벡터 양자화 유형입니다. 임베딩이 float 또는 double 벡터인 경우에만 이 설정을 사용합니다.

다음 값 중 하나를 지정할 수 있습니다.

  • none - 벡터 임베딩에 대한 자동 양자화를 수행하지 않음을 나타냅니다. 수집을 위해 사전에 양자화된 벡터가 있는 경우 이 설정을 사용합니다. 생략하면 이 값이 기본값 입니다.

  • scalar - 값을 1 바이트 정수로 변환하는 스칼라 양자화를 나타냅니다.

  • binary - 값을 단일 비트로 변환하는 이진 양자화를 나타냅니다. 이 값을 사용하려면 numDimensions 이 8의 배수여야 합니다.

    정밀도가 중요한 경우 binary 대신 none 또는 scalar 를 선택합니다.

To learn more, see About Quantization.

indexingMethod

문자열

옵션

벡터 필드 의 인덱스 구조입니다. 값은 다음과 같습니다.

  • hnsw - 유사한 벡터가 연결된 그래프 기반 인덱스 의 경우

  • flat - 플랫, 그래프가 아닌 인덱스 의 경우

If omitted, defaults to hnsw. If you specify hnsw, MongoDB Vector Search performs ANN search over the Hierarchical Navigable Small Worlds graph and ENN search over full-fidelity vectors. You can also specify hnswOptions.

If you specify flat, MongoDB Vector Search performs a full scan over full-fidelity or quantized vectors. During an ANN search, MongoDB Vector Search ignores the settings for numCandidates. For ENN search, MongoDB Vector Search performs a full scan over full-fidelity vectors.

hnswOptions

객체

옵션

Parameters to use for Hierarchical Navigable Small Worlds graph construction. If omitted, uses the default values for the maxEdges and numEdgeCandidates parameters.

중요: 이 기능은 미리 보기 기능으로 제공됩니다. 기본값을 수정하면 MongoDB Search 인덱스와 쿼리에 부정적인 영향을 미칠 수 있습니다.

hnswOptions.
maxEdges

Int

옵션

Maximum number of edges (or connections) that a node can have in the Hierarchical Navigable Small Worlds graph. Value can be between 16 and 64, both inclusive. If omitted, defaults to 16. For example, for a value of 16, each node can have a maximum of sixteen outgoing edges at each layer of the Hierarchical Navigable Small Worlds graph.

A higher number improves :recall (accuracy of search results) because the graph is better connected. However, this also increases query and indexing time by increasing the number of neighbors to evaluate per graph node, and requires more memory to store the additional nodes for each connection in the Hierarchical Navigable Small Worlds graph.

hnswOptions.
numEdgeCandidates

Int

옵션

쿼리 시 numCandidates와 유사하게, 이 매개변수는 새 노드에 연결할 가장 가까운 노드를 찾기 위해 평가할 최대 노드 수를 제어합니다. 값은 100~ 3200일 수 있으며, 두 값 모두 포함됩니다. 이를 생략하는 경우 기본값은 100입니다.

숫자가 높을수록 고품질 연결을 가진 그래프가 제공되어 검색 품질(재현율)을 향상시킬 수 있지만, 쿼리 지연 시간이 증가할 수도 있습니다.

The following index definition example uses the sample_mflix.embedded_movies collection in the sample data. After you load the collection, you can use the following example to index the plot_embedding_voyage_3_large field as the vector type for running queries using the vectorSearch (MongoDB Search Operator). For a sample query to run against this index, see Examples.

이 인덱스 정의는 동적으로 인덱싱 가능한 모든 필드를 기본값 typeSet를 사용하여 자동으로 인덱싱하고, plot_embedding_voyage_3_large 필드를 vector 유형으로 다음 설정을 사용하여 인덱싱합니다.

  • 2048 차원의 수

  • dotProduct 유사성 함수

  • scalar 양자화

  • hnsw (기본값) 인덱싱 메서드