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

vectorSearch (MongoDB Search 연산자)

vectorSearch 연산자 지정된 필드의 벡터 임베딩에 대해 ANN 또는 ENN 검색 수행합니다. 이 연산자 사용하여 퍼지 검색, 구문 일치, 위치 필터링, 와일드카드 패턴 일치 등과 같은 분석된 텍스트 기능을 시맨틱 검색 과 함께 추가할 수 있습니다.

vectorSearch 의 구문은 다음과 같습니다:

{
"$search": {
"index": "<index name>", // optional, defaults to "default"
"vectorSearch": {
"exact": true | false,
"filter": {<operator-specification>},
"limit": <number-of-results>,
"numCandidates": <number-of-candidates>,
"path": "<field-to-search>",
"queryVector": [<array-of-numbers>],
"score": {<options>}
}
}
}

vectorSearch 다음 필드를 사용하여 쿼리를 구성합니다.

필드
유형
필요성
설명

exact

부울

옵션

numCandidates를 생략한 경우 필수 항목입니다.

등가 최근접 이웃 또는 근사 최근접 이웃 검색을 실행할지 여부를 지정하는 플래그입니다. 값은 다음 중 하나일 수 있습니다:

  • false - 근사 최근접 이웃 검색 실행 시

  • true - 등가 최근접 이웃 검색 실행 시

생략하는 경우 기본값은 false입니다.

MongoDB Vector Search supports ANN search on Atlas clusters running MongoDB v6.0.11, v7.0.2, or later and ENN search on clusters running MongoDB v6.0.16, v7.0.10, v7.3.2, or later. You can also use MongoDB Vector Search with self-managed or local Atlas deployments that you create with the Atlas CLI.

filter

객체

옵션

MongoDB Search 연산자를 사용하여 메타데이터 또는 특정 검색 기준에 따라 문서를 사전 필터링할 수 있습니다.

To learn more, see Pre-Filter.

limit

Int

필수 사항

결과에 반환할 문서 수(int 유형만 해당)입니다. numCandidates를 지정하는 경우 이 값은 numCandidates 값을 초과할 수 없습니다.

On sharded clusters, you must use $limit after the $search stage to limit the number of documents in the results.

numCandidates

Int

옵션

exactfalse이거나 생략된 경우 이 필드는 필수입니다.

검색 중에 사용할 가장 가까운 이웃의 수입니다. 값은 (<=)10000보다 작거나 같아야 합니다. 반환할 문서 수보다 작은 숫자는 지정할 수 없습니다(limit).

정확도를 높이기 위해 반환할 문서 수(limit)보다 최소 20배 더 높은 숫자를 지정하는 것이 좋습니다.

This overrequest pattern is the recommended way to trade off latency and :recall in your ANN searches, and we recommend tuning this parameter based on your specific dataset size and query requirements.

path

문자열

필수 사항

검색할 인덱싱된 벡터 유형 필드입니다.

queryVector

정수 또는 실수 배열

필수 사항

Array of numbers of float32, BSON BinData vectors with subtype float32, or BSON BinData vectors with subtype int1 or int8 type that represent the query vector.

To learn more about generating BSON binData vectors with subtype float32, int8, or int1, see How to Ingest Pre-Quantized Vectors.

배열 크기는 필드에 대한 인덱스 정의에서 지정된 벡터 차원 수(numDimensions)와 일치해야 합니다.

데이터를 임베드할 때 사용한 것과 동일한 모델을 사용하여 쿼리를 임베드해야 합니다.

벡터 하위 유형이 동일한 경우, full-fidelity 벡터를 사용하여 임베딩을 쿼리할 수 있습니다. binData 벡터는 하위 유형 float32에서만 가능합니다. 다른 하위 유형 (int8 또는 int1)을 사용하는 경우 MongoDB Search는 결과나 오류를 반환하지 않습니다.

score

객체

옵션

일치하는 검색 텀 결과에 할당된 점수입니다. 다음 옵션 중 하나를 사용하여 기본 점수를 수정합니다.

  • boost결과 점수에 주어진 숫자를 곱합니다.

  • constant결과 점수를 주어진 숫자로 바꿉니다.

  • function: 주어진 표현식을 사용하여 결과 점수를 대체합니다.

쿼리에서 score 사용에 대한 자세한 내용은 결과에서 문서 채점하기를 참조하십시오.

vectorSearch 연산자를 사용하여 검색할 필드를 인덱싱해야 합니다. MongoDB Search 인덱스 정의에서 다음 유형의 필드를 인덱싱할 수 있습니다.

  • 벡터 임베딩을 포함하는 필드. 이 필드는 쿼리 path 옵션에서 지정한 필드입니다.

  • 문서를 사전 필터링하는 필드. 이 필드는 쿼리 filter 옵션에서 지정한 필드입니다.

문서를 사전 필터링하여 시맨틱 검색 범위를 좁힐 수 있습니다. filter 필드 에서 지원되는 MongoDB Search 연산자 사용하여 문서를 쿼리 하고 필터하다 .

중요

필터링된 쿼리는 일반적으로 이에 상응하는 필터링되지 않은 쿼리 보다 느립니다.

vector 유형의 인덱스 정의에서 데이터를 필터링할 필드를 반드시 인덱싱해야 합니다.

You can include the score of each document in your search results. Specify the $meta expression with the searchScore value in the $project stage. You can also specify the searchScoreDetails value for the scoreDetails field $meta expression for a detailed breakdown of the score.

자세한 내용은 결과에서 문서의 점수를 매기기점수 세부 정보 반환을 참조하세요.

vectorSearch 연산자는 쿼리에서 최상위 연산자여야 합니다. 따라서 다음 MongoDB Search 연산자에서는 vectorSearch 연산자를 사용할 수 없습니다.

You can't use the vectorSearch operator to query fields indexed using a vectorSearch type index.

다음 $search 옵션은 vectorSearch 연산자와 함께 사용할 수 없습니다:

MongoDB Search Playground에서는 $search 쿼리를 vectorSearch 연산자와 함께 실행할 수 없습니다.

The following examples use the sample_mflix.embedded_movies collection from the sample data. If you load the sample data and create the sample index on the collection, you can run the following ANN and ENN queries against the collection after replacing the <connection-string> and <index-name> placeholders in the queries.