Docs Menu
Docs Home
/ /

MongoDB Vector Search 결과 설명

메서드를 사용하여 MongoDB Vector Search 쿼리 explain 실행 쿼리 쿼리 내부적으로 실행 된 방식을 설명하는 실행 쿼리 계획 계획이 포함된 BSON 문서반환합니다.

explain 명령

db.<myCollection>.explain("<verbosity>").aggregate([
{
"$vectorSearch": {
"exact": true | false,
"filter": {<filter-specification>},
"index": "<index-name>",
"limit": <number-of-results>,
"numCandidates": <number-of-candidates>,
"path": "<field-to-search>",
"queryVector": [<array-of-numbers>],
"explainOptions": {
"traceDocumentIds": [<array-of-document-IDs>]
}
}
}
])

상세 모드 explain 의 동작과 반환되는 정보의 양을 제어합니다. 값은 상세도가 낮은 순서대로 다음 중 하나일 수 있습니다.

쿼리에 대한 실행 쿼리 가 포함된 stats 필드를 포함한 쿼리 계획 에 대한 정보입니다. 계획 선택 중에 캡처한 부분 실행 데이터를 포함합니다.

쿼리에 대한 실행 통계가 포함된 stats 필드를 포함한 쿼리 계획에 대한 정보입니다.

queryPlanner(기본값)

쿼리 계획에 대한 정보입니다. 쿼리에 대한 실행 통계를 포함하는 stats 필드는 포함되지 않습니다.

explain 메서드는 다음 필드가 있는 BSON 문서 반환합니다.

옵션
유형
필요성
목적

collectors

문서

옵션

수집기에 대한 실행 통계를 설명합니다.

metadata

문서

옵션

유용한 메타데이터를 포함합니다.

query

문서

옵션

쿼리 에 대한 실행 통계를 설명합니다. 이는 indexPartitionExplain의 최상위 수준에는 존재하지 않습니다.

resultMaterialization

문서

옵션

쿼리 실행 후 문서별 데이터 검색과 관련된 세부 정보입니다. queryPlanner 상세도 모드 에서는 이 값이 반환되지 않습니다.

resourceUsage

문서

옵션

쿼리가 실행되었을 때 쿼리의 리소스 사용량 세부 정보를 제공합니다. queryPlanner 상세 수준 모드에서는 반환되지 않습니다.

vectorTracing

객체 배열

옵션

지정된 문서의 벡터에 대한 다음과 같은 세부 정보를 추적합니다.

luceneVectorSegmentStats

객체 배열

옵션

쿼리 실행의$vectorSearch 루센별 세그먼트 세부 정보입니다.

collectors 은 다음 필드 있는 BSON 문서 입니다.

필드
유형
필요성
목적

allCollectorStats

문서

필수 사항

쿼리 의 모든 수집기 통계입니다. 보고된 통계는 쿼리 에 사용된 모든 수집기의 최대값 또는 모든 하위 수집기의 통계 합계를 나타냅니다. 타이밍 통계는 전체 쿼리 에 대해 모든 수집기에서 소요된 총 시간을 반영하기 위해 합산됩니다. 자세한 학습 은 allCollectorStats를 참조하세요.

allCollectorStats 은 쿼리 에 지정된 모든 수집기의 수집기 통계를 설명하는 BSON 문서 입니다. 여기에는 다음과 같은 키가 포함되어 있습니다.

필드
설명

collect

수집기가 수집한 결과의 지속 시간과 수량을 추적합니다.

competitiveIterator

수집기에서 competitiveIterator가 요청된 총 지속 시간과 횟수를 추적하는 통계입니다.

setScorer

수집기에 설정된 점수 계산기의 총 지속 시간과 횟수를 추적하는 통계입니다.

metadata는 다음과 같은 유용한 메타데이터를 포함합니다.

필드
유형
필요성
목적

mongotVersion

문자열

옵션

mongot의 현재 버전입니다.

mongotHostName

문자열

옵션

mongot 호스트를 식별하는 사람이 읽을 수 있는 레이블입니다.

indexName

문자열

옵션

쿼리 에 사용된 MongoDB Vector Search 인덱스 .

cursorOptions

문서

옵션

mongot에 커서 옵션이 제공됩니다.

totalLuceneDocs

Integer

옵션

삭제된 문서를 포함하여 인덱스 에 있는 총 문서 수입니다.

explain 응답은 쿼리의 실행 통계를 설명하는 키와 값이 포함된 BSON 문서입니다. 결과 세트의 explain 문서에는 다음 필드가 포함되어 있습니다.

필드
유형
필요성
목적

path

문자열

옵션

루트가 아닌 경우에만 쿼리된 임베딩 필드 의 경로입니다.

type

문자열

필수 사항

벡터 검색 쿼리 유형의 이름입니다. 자세한 내용은 query 를 참조하세요.

args

문서

필수 사항

벡터 검색 쿼리 정보입니다. 자세한 내용은 query 를 참조하세요.

stats

문서

옵션

explainexecutionStats 또는 allPlansExecution 상세 수준으로 실행된 경우 쿼리에 대한 stats입니다.

설명 응답 에는 쿼리 내부적으로 실행된 방식에 대한 정보가 포함되어 있습니다. args 필드 에는 다음과 같은 세부 정보가 포함되어 있습니다.

  • 쿼리 유형

  • 각 쿼리 유형에 대한 구조화된 요약 예시

  • 구조화된 요약의 쿼리 옵션

다음 섹션에서는 구조화된 요약의 쿼리 유형과 필드에 대해 설명합니다.

WrappedKnnQuery

여러 쿼리를 결합하는 ANN 벡터 검색에 사용되는 래퍼 쿼리입니다. 구조화된 요약에는 다음 옵션에 대한 세부 정보가 포함되어 있습니다.

필드
유형
필요성
설명

query

배열

필수 사항

벡터 검색 에 사용되는 하위 쿼리의 배열로, 일반적으로 KnnFloatVectorQueryDocAndScoreQuery를 포함합니다.

KnnFloatVectorQuery

부동 소수점 벡터에 대한 ANN 검색과 관련된 쿼리 유형입니다. 구조화된 요약에는 다음 옵션에 대한 세부 정보가 포함되어 있습니다.

필드
유형
필요성
설명

field

문자열

필수 사항

검색 중인 벡터 필드 경로 .

k

Integer

필수 사항

조회 할 가장 가까운 이웃의 수입니다.

DocAndScoreQuery

문서 일치 및 점수 산정을 처리하는 쿼리 유형입니다. 구조화된 요약에는 일반적으로 쿼리 실행에 대한 통계가 포함됩니다.

ExactVectorSearchQuery

ENN 벡터 검색을 위한 쿼리 유형입니다. 구조화된 요약에는 다음 옵션에 대한 세부 정보가 포함되어 있습니다.

필드
유형
필요성
설명

field

문자열

필수 사항

검색 중인 벡터 필드 경로 .

similarityFunction

문자열

필수 사항

사용된 유사성 함수(dotProduct, cosine 또는 euclidean)입니다.

filter

문서

옵션

벡터 검색 범위를 제한하는 사전 필터 쿼리 .

BooleanQuery

벡터 검색 쿼리 에서 사전 필터를 사용하는 경우 설명 결과에 BooleanQuery 유형이 포함됩니다. 이 유형의 필드 및 사전 필터 쿼리 와 관련된 기타 쿼리 유형에 대해 자세히 학습하려면 MongoDB 검색 설명 페이지의 쿼리 유형을 참조하세요.

DefaultQuery

다른 쿼리 에서 명시적으로 정의되지 않은 쿼리는 기본값 쿼리 사용하여 직렬화됩니다. 구조화된 요약에는 다음 옵션에 대한 세부 정보가 포함되어 있습니다.

필드
유형
필요성
설명

queryType

문자열

필수 사항

쿼리 유형입니다.

executionStatsallPlansExecution 상세도 모드에 대한 explain 응답에는 stats 쿼리가 쿼리 실행의 다양한 단계 에서 소비하는 시간 에 대한 정보가 포함된 필드가 포함되어 있습니다.

타이밍 분석은 쿼리 실행 영역 과 관련된 실행 통계를 설명합니다. 다음 필드에는 타이밍 분석이 표시됩니다.

필드
유형
설명

millisElapsed

Long

쿼리 의 하위 항목이 이 영역에서 보낸 시간을 포함하여 이 영역에서 작업을 수행하는 데 경과된 대략적인 벽시계 시간입니다. 값은 이 영역에서 작업을 수행하는 동안 경과된 대략적인 시간(밀리초)입니다.

invocationCounts

문서

이 영역에 포함된 작업 호출의 횟수입니다. 값은 작업 이름과 해당 호출 횟수의 맵입니다.

다음 쿼리 영역에 대한 통계를 사용할 수 있습니다.

옵션
설명

context

벡터 검색 쿼리 실행과 관련된 통계입니다. 이 영역에 호출 횟수가 열거되는 두 가지 작업이 있습니다.

createScorer

점수 산정기는 문서를 반복하고 각 문서에 대한 점수를 생성합니다. createScorer 호출은 점수 산정을 담당하는 객체를 생성합니다. 이 작업과 관련된 시간은 실제로 문서에 점수를 매기는 데 소요된 시간이 아닙니다. 개수에는 scorerSupplier 호출 수가 포함됩니다.

createWeight

가중치는 쿼리 및 IndexSearcher 과 관련된 상태를 저장합니다. 개수에는 createWeight 호출 수가 포함됩니다.

이 영역에서 소요된 시간은 쿼리 구조와 관련이 있으며, 반복되고 점수가 매겨지는 결과 수에 기반하지 않습니다.

예를 들면 다음과 같습니다.

"context" : {
"millisElapsed" : NumberDouble(4.934751),
"invocationCounts" : {
"createWeight" : NumberLong(1),
"createScorer" : NumberLong(10)
}
}

match

결과 문서를 반복하고 일치시키는 것과 관련된 통계입니다. 이 통계는 어떤 문서가 다음 일치 항목인지 결정하는 데 걸리는 시간을 보여줍니다. 결과 일치에 소요되는 시간은 쿼리의 특성에 따라 크게 달라질 수 있습니다. 이 영역에서 호출 횟수가 열거되는 두 가지 작업이 있습니다.

nextDoc

결과 집합의 다음 문서로 이동하도록 요청합니다. 여기에는 과거의 건너뛰기 또는 다음 일치 항목을 찾는 데 필요한 기타 작업을 식별하고 이동하는 등이 포함됩니다. 개수에는 nextDocadvance 호출 수가 포함됩니다.

refineRoughMatch

보다 철저한 일치를 수행합니다. 일부 쿼리는 문서가 먼저 '대략' 일치하는 2단계 프로세스로 실행되고, 첫 번째 대략적인 일치를 충족한 후에만 두 번째, 보다 철저한 단계에서 확인됩니다. refineRoughMatch 작업은 2단계 프로세스 중 두 번째 단계입니다. 개수에는 refineRoughMatch 호출 수가 포함됩니다.

예를 들면 다음과 같습니다.

"match" : {
"millisElapsed" : NumberDouble(4.901597),
"invocationCounts" : {
"nextDoc" : NumberLong(541),
"refineRoughMatch" : NumberLong(0)
}
}

score

결과 세트의 문서 점수 산정과 관련된 통계입니다. 이 영역에서 호출 횟수가 열거되는 두 가지 작업이 있습니다.

score

결과 세트의 각 문서에 점수를 매깁니다. 개수에는 score 호출 수가 포함됩니다.

setMinCompetitiveScore

점수가 지정된 값보다 낮은 문서를 무시합니다. 점수가 경쟁적이지 않은 일부 임계값보다 낮은 문서를 무시하여 쿼리가 수행되는 점수 산정 작업 수를 줄일 수 있었음을 나타냅니다. 개수에는 setMinCompetitiveScore 호출 수가 포함됩니다.

예를 들면 다음과 같습니다.

"score" : {
"millisElapsed" : NumberDouble(3.931312),
"invocationCounts" : {
"score" : NumberLong(536),
"setMinCompetitiveScore" : NumberLong(0)
}
}

resourceUsage 문서는 쿼리 실행에 사용된 리소스를 보여줍니다. 다음 필드를 포함합니다.

필드
유형
필요성
목적

majorFaults

Long

필수 사항

쿼리 실행 중 시스템이 메모리에서 필요한 데이터를 찾지 못해 디스크와 같은 백업 저장소에서 읽게 될 때 발생하는 주요 페이지 폴트 수입니다.

minorFaults

Long

필수 사항

데이터가 페이지 캐시에 있지만 아직 프로세스의 페이지 테이블에 매핑되지 않은 경우 발생하는 경미한 페이지 폴트의 수입니다.

userTimeMs

Long

필수 사항

사용자 공간에서 소요된 CPU 시간(밀리초)입니다.

systemTimeMs

Long

필수 사항

시스템 공간에서 소요된 CPU 시간(단위: 밀리초)입니다.

maxReportingThreads

Integer

필수 사항

모든 배치에서 쿼리 실행 중 mongot가 사용한 최대 스레드 수입니다. 동시 실행되지 않는 설명 쿼리의 경우 값은 1입니다.

numBatches

Integer

필수 사항

쿼리 처리 시 요청된 mongot의 총 배치 수입니다.

vectorTracing 배열 에는 문서 당 하나씩 객체 목록이 포함되며 문서 의 벡터에 대한 다음 세부 정보를 포함합니다.

필드
유형
필요성
목적

visited

부울

필수 사항

쿼리 실행 중에 추적된 벡터를 방문했는지 여부를 지정하는 플래그입니다.

dropReason

문자열

조건부

벡터를 삭제하는 이유입니다. 이는 벡터를 방문하여 결과에서 삭제한 경우에만 표시됩니다. 값은 다음과 같습니다.

  • Merge

  • NonCompetitiveScore

  • Filter

  • Rescoring

vectorSearchScore

Double

조건부

벡터와 관련된 점수입니다. 이는 벡터를 방문한 경우에만 표시됩니다.

luceneSegment

Integer

필수 사항

벡터가 속한 루센 세그먼트 번호입니다. 자세한 학습 luceneVectorSegmentStats 은 를 참조하세요.

unreachable

부울

조건부

벡터에 연결할 수 없는지 여부를 지정하는 플래그입니다. 이는 벡터에 연결할 수 없는 경우에만 존재합니다.

luceneVectorSegmentStats 객체의 배열 에는 쿼리 실행에 대한 루센 세그먼트별 분석이 포함되어 $vectorSearch 있습니다. 각 세그먼트는 숫자로 식별되며 쿼리 실행 세부 정보를 설명하는 매개변수를 포함합니다.

{
"0": {
"executionType": "Approximate",
"approximateTimeMillis": 0.10825,
"filterMatchedDocsCount": 0,
"docCount": 100
},
"1": {
"executionType": "Exact",
"exactTimeMillis": 0.10825,
"filterMatchedDocsCount": 0,
"docCount": 55
},
"2": {
"executionType": "ApproximateToExactFallback",
"approximateTimeMillis": 0.10825,
"exactTimeMillis": 0.10825,
"filterMatchedDocsCount": 0,
"docCount": 55
}
}
필드
유형
필요성
목적

executionType

문자열

필수 사항

실행 전략. 값은 다음 중 하나일 수 있습니다.

  • Approximate

  • Exact

  • ApproximateToExactFallback

approximateStage

Float

조건부

대략적인 단계의 시간(밀리초)입니다. ApproximateApproximateFallbackToExact 실행 유형에 대해서만 반환됩니다.

exactStage

Float

조건부

정확함 단계의 시간(밀리초)입니다. ExactApproximateFallbackToExact 실행 유형에 대해서만 반환됩니다.

filterMatchedDocsCount

Integer

옵션

쿼리 에 사전 필터를 지정한 경우 쿼리 필터하다 와 일치하는 문서 수입니다.

docCount

Integer

필수 사항

세그먼트에 있는 총 문서 수입니다.

다음 예제에서는 샘플 ANNENN 쿼리에 explain 메서드를 사용합니다. 자신의 환경에서 다음 예제를 실행 하려면 먼저 을(를) 사용하여 MongoDB Vector Search 빠른 시작을 완료해야 mongosh 합니다.

다음 예시 상세도 모드 사용하여 필드 plot_embedding_voyage_3_large 에 대한 ANN 및 ENN 벡터 검색 쿼리 allPlansExecution 에서 explain 메서드를 실행합니다.

db.embedded_movies.explain("allPlansExecution").aggregate([
{
"$vectorSearch": {
"index": "vector_index",
"path": "plot_embedding_voyage_3_large",
"queryVector": QUERY_EMBEDDING,
"numCandidates": 150,
"limit": 10
}
}
])
1{
2 explainVersion: '1',
3 stages: [
4 {
5 '$vectorSearch': {
6 index: 'vector_index',
7 path: 'plot_embedding_voyage_3_large',
8 queryVector: 'redacted',
9 numCandidates: 150,
10 limit: 10,
11 explain: {
12 query: {
13 type: 'WrappedKnnQuery',
14 args: {
15 query: [
16 {
17 type: 'InstrumentableKnnFloatVectorQuery',
18 args: {
19 field: '$type:knnVector/plot_embedding_voyage_3_large',
20 k: 150
21 },
22 stats: {
23 context: { millisElapsed: 0 },
24 match: { millisElapsed: 0 },
25 score: { millisElapsed: 0 }
26 }
27 },
28 {
29 type: 'DocAndScoreQuery',
30 args: {},
31 stats: {
32 context: {
33 millisElapsed: 1.378949,
34 invocationCounts: {
35 createWeight: Long('1'),
36 createScorer: Long('4')
37 }
38 },
39 match: {
40 millisElapsed: 0.341389,
41 invocationCounts: { nextDoc: Long('152') }
42 },
43 score: {
44 millisElapsed: 0.205415,
45 invocationCounts: {
46 score: Long('150'),
47 setMinCompetitiveScore: Long('26')
48 }
49 }
50 }
51 }
52 ]
53 },
54 stats: {
55 context: {
56 millisElapsed: 57.285674,
57 invocationCounts: {
58 vectorExecution: Long('1'),
59 createWeight: Long('1'),
60 createScorer: Long('4')
61 }
62 },
63 match: {
64 millisElapsed: 0.341389,
65 invocationCounts: { nextDoc: Long('152') }
66 },
67 score: {
68 millisElapsed: 0.205415,
69 invocationCounts: {
70 score: Long('150'),
71 setMinCompetitiveScore: Long('26')
72 }
73 }
74 }
75 },
76 collectors: {
77 allCollectorStats: {
78 millisElapsed: 0.840381,
79 invocationCounts: {
80 collect: Long('150'),
81 competitiveIterator: Long('2'),
82 setScorer: Long('2')
83 }
84 }
85 },
86 metadata: {
87 mongotVersion: '1.54.0',
88 mongotHostName: '<hostname>.mongodb.net',
89 indexName: 'vector_index',
90 lucene: { totalSegments: 2, totalDocs: 3483 }
91 },
92 resourceUsage: {
93 majorFaults: Long('0'),
94 minorFaults: Long('0'),
95 userTimeMs: Long('0'),
96 systemTimeMs: Long('0'),
97 maxReportingThreads: 1,
98 numBatches: 1
99 },
100 luceneVectorSegmentStats: [
101 {
102 id: '_0',
103 executionType: 'Approximate',
104 docCount: 1952,
105 approximateStage: { millisElapsed: 32.916505 }
106 },
107 {
108 id: '_1',
109 executionType: 'Approximate',
110 docCount: 1531,
111 approximateStage: { millisElapsed: 8.661519 }
112 }
113 ]
114 }
115 },
116 nReturned: Long('10'),
117 executionTimeMillisEstimate: Long('256')
118 },
119 {
120 '$_internalSearchIdLookup': {
121 limit: Long('10'),
122 subPipeline: [
123 { '$match': { _id: { '$eq': '_id placeholder' } } }
124 ],
125 totalDocsExamined: Long('10'),
126 totalKeysExamined: Long('10'),
127 numDocsFilteredByIdLookup: Long('0')
128 },
129 nReturned: Long('10'),
130 executionTimeMillisEstimate: Long('256')
131 }
132 ],
133 queryShapeHash: '2E39BED257F2B59D3F8652E1A81A18B1140602C4E253DED9FE208D584EA00083',
134 serverInfo: {
135 host: '<hostname>.mongodb.net',
136 port: 27017,
137 version: '8.2.1-rc1',
138 gitVersion: '3312bdcf28aa65f5930005e21c2cb130f648b8c3'
139 },
140 serverParameters: {
141 internalQueryFacetBufferSizeBytes: 104857600,
142 internalQueryFacetMaxOutputDocSizeBytes: 104857600,
143 internalLookupStageIntermediateDocumentMaxSizeBytes: 104857600,
144 internalDocumentSourceGroupMaxMemoryBytes: 104857600,
145 internalQueryMaxBlockingSortMemoryUsageBytes: 104857600,
146 internalQueryProhibitBlockingMergeOnMongoS: 0,
147 internalQueryMaxAddToSetBytes: 104857600,
148 internalDocumentSourceSetWindowFieldsMaxMemoryBytes: 104857600,
149 internalQueryFrameworkControl: 'trySbeRestricted',
150 internalQueryPlannerIgnoreIndexWithCollationForRegex: 1
151 },
152 command: {
153 aggregate: 'embedded_movies',
154 pipeline: [
155 {
156 '$vectorSearch': {
157 index: 'vector_index',
158 path: 'plot_embedding_voyage_3_large',
159 queryVector: [
160 -0.034731735, 0.008558298, -0.0153717, -0.029912498, 0.011549547,
161 ...,
162 -0.006688767, 0.047527634, 0.040714234
163 ],
164 numCandidates: 150,
165 limit: 10
166 }
167 }
168 ],
169 cursor: {},
170 '$db': 'sample_mflix'
171 },
172 ok: 1,
173 '$clusterTime': {
174 clusterTime: Timestamp({ t: 1759341228, i: 32 }),
175 signature: {
176 hash: Binary.createFromBase64('BsaUr/khHU1Fyl5/g8htqoavlU8=', 0),
177 keyId: Long('7553982574624768005')
178 }
179 },
180 operationTime: Timestamp({ t: 1759341228, i: 32 })
181}
db.embedded_movies.explain("allPlansExecution").aggregate([
{
"$vectorSearch": {
"index": "vector_index",
"path": "plot_embedding_voyage_3_large",
"queryVector": QUERY_EMBEDDING,
"exact": true,
"limit": 10
}
}
])
{
explainVersion: '1',
stages: [
{
'$vectorSearch': {
index: 'vector_index',
path: 'plot_embedding_voyage_3_large',
queryVector: 'redacted',
exact: true,
limit: 10,
explain: {
query: {
type: 'ExactVectorSearchQuery',
args: {
field: '$type:knnVector/plot_embedding_voyage_3_large',
similarityFunction: 'dotProduct',
filter: {
type: 'DefaultQuery',
args: { queryType: 'FieldExistsQuery' },
stats: {
context: {
millisElapsed: 0.756254,
invocationCounts: {
createWeight: Long('1'),
createScorer: Long('4')
}
},
match: {
millisElapsed: 3.835071,
invocationCounts: { nextDoc: Long('3405') }
},
score: { millisElapsed: 0 }
}
}
},
stats: {
context: {
millisElapsed: 1.271846,
invocationCounts: { createWeight: Long('1'), createScorer: Long('4') }
},
match: {
millisElapsed: 7.699638,
invocationCounts: { nextDoc: Long('3405') }
},
score: {
millisElapsed: 139.077653,
invocationCounts: {
score: Long('3403'),
setMinCompetitiveScore: Long('63')
}
}
}
},
collectors: {
allCollectorStats: {
millisElapsed: 146.798572,
invocationCounts: {
collect: Long('3403'),
competitiveIterator: Long('2'),
setScorer: Long('2')
}
}
},
metadata: {
mongotVersion: '1.54.0',
mongotHostName: '<hostname>.mongodb.net',
indexName: 'vector_index',
lucene: { totalSegments: 2, totalDocs: 3483 }
},
resourceUsage: {
majorFaults: Long('0'),
minorFaults: Long('0'),
userTimeMs: Long('0'),
systemTimeMs: Long('0'),
maxReportingThreads: 1,
numBatches: 1
}
}
},
nReturned: Long('10'),
executionTimeMillisEstimate: Long('208')
},
{
'$_internalSearchIdLookup': {
limit: Long('10'),
subPipeline: [
{ '$match': { _id: { '$eq': '_id placeholder' } } }
],
totalDocsExamined: Long('10'),
totalKeysExamined: Long('10'),
numDocsFilteredByIdLookup: Long('0')
},
nReturned: Long('10'),
executionTimeMillisEstimate: Long('208')
}
],
queryShapeHash: '2E39BED257F2B59D3F8652E1A81A18B1140602C4E253DED9FE208D584EA00083',
serverInfo: {
host: '<hostname>.mongodb.net',
port: 27017,
version: '8.2.1-rc1',
gitVersion: '3312bdcf28aa65f5930005e21c2cb130f648b8c3'
},
serverParameters: {
internalQueryFacetBufferSizeBytes: 104857600,
internalQueryFacetMaxOutputDocSizeBytes: 104857600,
internalLookupStageIntermediateDocumentMaxSizeBytes: 104857600,
internalDocumentSourceGroupMaxMemoryBytes: 104857600,
internalQueryMaxBlockingSortMemoryUsageBytes: 104857600,
internalQueryProhibitBlockingMergeOnMongoS: 0,
internalQueryMaxAddToSetBytes: 104857600,
internalDocumentSourceSetWindowFieldsMaxMemoryBytes: 104857600,
internalQueryFrameworkControl: 'trySbeRestricted',
internalQueryPlannerIgnoreIndexWithCollationForRegex: 1
},
command: {
aggregate: 'embedded_movies',
pipeline: [
{
'$vectorSearch': {
index: 'vector_index',
path: 'plot_embedding_voyage_3_large',
queryVector: [
-0.034731735, 0.008558298, -0.0153717, -0.029912498, 0.011549547,
...,
-0.006688767, 0.047527634, 0.040714234
],
exact: true,
limit: 10
}
}
],
cursor: {},
'$db': 'sample_mflix'
},
ok: 1,
'$clusterTime': {
clusterTime: Timestamp({ t: 1759341655, i: 1 }),
signature: {
hash: Binary.createFromBase64('/pUN/IbVV/OKyakbZcIug8HRS8M=', 0),
keyId: Long('7553982574624768005')
}
},
operationTime: Timestamp({ t: 1759341655, i: 1 })
}

다음 예시 상세도 모드 사용하여 필드 plot_embedding_voyage_3_large 에 대한 ANN 및 ENN 벡터 검색 쿼리 queryPlanner 에서 explain 메서드를 실행합니다.

db.embedded_movies.explain("queryPlanner").aggregate([
{
"$vectorSearch": {
"index": "vector_index",
"path": "plot_embedding_voyage_3_large",
"queryVector": QUERY_EMBEDDING,
"numCandidates": 150,
"limit": 10
}
}
])
{
explainVersion: '1',
stages: [
{
'$vectorSearch': {
index: 'vector_index',
path: 'plot_embedding_voyage_3_large',
queryVector: 'redacted',
numCandidates: 150,
limit: 10,
explain: {
query: {
type: 'WrappedKnnQuery',
args: {
query: [
{
type: 'InstrumentableKnnFloatVectorQuery',
args: {
field: '$type:knnVector/plot_embedding_voyage_3_large',
k: 150
}
},
{ type: 'DocAndScoreQuery', args: {} }
]
}
},
metadata: {
mongotVersion: '1.54.0',
mongotHostName: '<hostname>.mongodb.net',
indexName: 'vector_index',
lucene: { totalSegments: 2, totalDocs: 3483 }
}
}
}
},
{
'$_internalSearchIdLookup': {
limit: Long('10'),
subPipeline: [
{ '$match': { _id: { '$eq': '_id placeholder' } } }
]
}
}
],
queryShapeHash: '2E39BED257F2B59D3F8652E1A81A18B1140602C4E253DED9FE208D584EA00083',
serverInfo: {
host: '<hostname>.mongodb.net',
port: 27017,
version: '8.2.1-rc1',
gitVersion: '3312bdcf28aa65f5930005e21c2cb130f648b8c3'
},
serverParameters: {
internalQueryFacetBufferSizeBytes: 104857600,
internalQueryFacetMaxOutputDocSizeBytes: 104857600,
internalLookupStageIntermediateDocumentMaxSizeBytes: 104857600,
internalDocumentSourceGroupMaxMemoryBytes: 104857600,
internalQueryMaxBlockingSortMemoryUsageBytes: 104857600,
internalQueryProhibitBlockingMergeOnMongoS: 0,
internalQueryMaxAddToSetBytes: 104857600,
internalDocumentSourceSetWindowFieldsMaxMemoryBytes: 104857600,
internalQueryFrameworkControl: 'trySbeRestricted',
internalQueryPlannerIgnoreIndexWithCollationForRegex: 1
},
command: {
aggregate: 'embedded_movies',
pipeline: [
{
'$vectorSearch': {
index: 'vector_index',
path: 'plot_embedding_voyage_3_large',
queryVector: [
-0.034731735, 0.008558298, -0.0153717, -0.029912498, 0.011549547,
...,
-0.006688767, 0.047527634, 0.040714234
],
numCandidates: 150,
limit: 10
}
}
],
cursor: {},
'$db': 'sample_mflix'
},
ok: 1,
'$clusterTime': {
clusterTime: Timestamp({ t: 1759341765, i: 1 }),
signature: {
hash: Binary.createFromBase64('rPjwbtfbjVrbcvkkN0ct/b1UYa8=', 0),
keyId: Long('7553982574624768005')
}
},
operationTime: Timestamp({ t: 1759341765, i: 1 })
}
db.embedded_movies.explain("queryPlanner").aggregate([
{
"$vectorSearch": {
"index": "vector_index",
"path": "plot_embedding_voyage_3_large",
"queryVector": QUERY_EMBEDDING,
"exact": true,
"limit": 10
}
}
])
{
explainVersion: '1',
stages: [
{
'$vectorSearch': {
index: 'vector_index',
path: 'plot_embedding_voyage_3_large',
queryVector: 'redacted',
exact: true,
limit: 10,
explain: {
query: {
type: 'ExactVectorSearchQuery',
args: {
field: '$type:knnVector/plot_embedding_voyage_3_large',
similarityFunction: 'dotProduct',
filter: {
type: 'DefaultQuery',
args: { queryType: 'FieldExistsQuery' }
}
}
},
metadata: {
mongotVersion: '1.54.0',
mongotHostName: '<hostname>.mongodb.net',
indexName: 'vector_index',
lucene: { totalSegments: 2, totalDocs: 3483 }
}
}
}
},
{
'$_internalSearchIdLookup': {
limit: Long('10'),
subPipeline: [
{ '$match': { _id: { '$eq': '_id placeholder' } } }
]
}
}
],
queryShapeHash: '2E39BED257F2B59D3F8652E1A81A18B1140602C4E253DED9FE208D584EA00083',
serverInfo: {
host: '<hostname>.mongodb.net',
port: 27017,
version: '8.2.1-rc1',
gitVersion: '3312bdcf28aa65f5930005e21c2cb130f648b8c3'
},
serverParameters: {
internalQueryFacetBufferSizeBytes: 104857600,
internalQueryFacetMaxOutputDocSizeBytes: 104857600,
internalLookupStageIntermediateDocumentMaxSizeBytes: 104857600,
internalDocumentSourceGroupMaxMemoryBytes: 104857600,
internalQueryMaxBlockingSortMemoryUsageBytes: 104857600,
internalQueryProhibitBlockingMergeOnMongoS: 0,
internalQueryMaxAddToSetBytes: 104857600,
internalDocumentSourceSetWindowFieldsMaxMemoryBytes: 104857600,
internalQueryFrameworkControl: 'trySbeRestricted',
internalQueryPlannerIgnoreIndexWithCollationForRegex: 1
},
command: {
aggregate: 'embedded_movies',
pipeline: [
{
'$vectorSearch': {
index: 'vector_index',
path: 'plot_embedding_voyage_3_large',
queryVector: [
-0.034731735, 0.008558298, -0.0153717, -0.029912498, 0.011549547,
...,
-0.006688767, 0.047527634, 0.040714234
],
exact: true,
limit: 10
}
}
],
cursor: {},
'$db': 'sample_mflix'
},
ok: 1,
'$clusterTime': {
clusterTime: Timestamp({ t: 1759342075, i: 1 }),
signature: {
hash: Binary.createFromBase64('jQiwcAMEmfzFnVU/pyb29TnYu0w=', 0),
keyId: Long('7553982574624768005')
}
},
operationTime: Timestamp({ t: 1759342075, i: 1 })
}

다음 예시 상세도 모드 사용하여 필드 plot_embedding_voyage_3_large 에 대한 ANN 및 ENN 벡터 검색 쿼리 executionStats 에서 explain 메서드를 실행합니다.

db.embedded_movies.explain("executionStats").aggregate([
{
"$vectorSearch": {
"index": "vector_index",
"path": "plot_embedding_voyage_3_large",
"queryVector": QUERY_EMBEDDING,
"numCandidates": 150,
"limit": 10
}
}
])
{
explainVersion: '1',
stages: [
{
'$vectorSearch': {
index: 'vector_index',
path: 'plot_embedding_voyage_3_large',
queryVector: 'redacted',
numCandidates: 150,
limit: 10,
explain: {
query: {
type: 'WrappedKnnQuery',
args: {
query: [
{
type: 'InstrumentableKnnFloatVectorQuery',
args: {
field: '$type:knnVector/plot_embedding_voyage_3_large',
k: 150
},
stats: {
context: { millisElapsed: 0 },
match: { millisElapsed: 0 },
score: { millisElapsed: 0 }
}
},
{
type: 'DocAndScoreQuery',
args: {},
stats: {
context: {
millisElapsed: 0.013013,
invocationCounts: {
createWeight: Long('1'),
createScorer: Long('4')
}
},
match: {
millisElapsed: 0.459619,
invocationCounts: { nextDoc: Long('152') }
},
score: {
millisElapsed: 0.179147,
invocationCounts: {
score: Long('150'),
setMinCompetitiveScore: Long('26')
}
}
}
}
]
},
stats: {
context: {
millisElapsed: 7.113224,
invocationCounts: {
vectorExecution: Long('1'),
createWeight: Long('1'),
createScorer: Long('4')
}
},
match: {
millisElapsed: 0.459619,
invocationCounts: { nextDoc: Long('152') }
},
score: {
millisElapsed: 0.179147,
invocationCounts: {
score: Long('150'),
setMinCompetitiveScore: Long('26')
}
}
}
},
collectors: {
allCollectorStats: {
millisElapsed: 0.868815,
invocationCounts: {
collect: Long('150'),
competitiveIterator: Long('2'),
setScorer: Long('2')
}
}
},
metadata: {
mongotVersion: '1.54.0',
mongotHostName: '<hostname>.mongodb.net',
indexName: 'vector_index',
lucene: { totalSegments: 2, totalDocs: 3483 }
},
resourceUsage: {
majorFaults: Long('0'),
minorFaults: Long('0'),
userTimeMs: Long('0'),
systemTimeMs: Long('0'),
maxReportingThreads: 1,
numBatches: 1
},
luceneVectorSegmentStats: [
{
id: '_1',
executionType: 'Approximate',
docCount: 1531,
approximateStage: { millisElapsed: 2.58089 }
},
{
id: '_0',
executionType: 'Approximate',
docCount: 1952,
approximateStage: { millisElapsed: 3.483542 }
}
]
}
},
nReturned: Long('10'),
executionTimeMillisEstimate: Long('29')
},
{
'$_internalSearchIdLookup': {
limit: Long('10'),
subPipeline: [
{ '$match': { _id: { '$eq': '_id placeholder' } } }
],
totalDocsExamined: Long('10'),
totalKeysExamined: Long('10'),
numDocsFilteredByIdLookup: Long('0')
},
nReturned: Long('10'),
executionTimeMillisEstimate: Long('30')
}
],
queryShapeHash: '2E39BED257F2B59D3F8652E1A81A18B1140602C4E253DED9FE208D584EA00083',
serverInfo: {
host: '<hostname>.mongodb.net',
port: 27017,
version: '8.2.1-rc1',
gitVersion: '3312bdcf28aa65f5930005e21c2cb130f648b8c3'
},
serverParameters: {
internalQueryFacetBufferSizeBytes: 104857600,
internalQueryFacetMaxOutputDocSizeBytes: 104857600,
internalLookupStageIntermediateDocumentMaxSizeBytes: 104857600,
internalDocumentSourceGroupMaxMemoryBytes: 104857600,
internalQueryMaxBlockingSortMemoryUsageBytes: 104857600,
internalQueryProhibitBlockingMergeOnMongoS: 0,
internalQueryMaxAddToSetBytes: 104857600,
internalDocumentSourceSetWindowFieldsMaxMemoryBytes: 104857600,
internalQueryFrameworkControl: 'trySbeRestricted',
internalQueryPlannerIgnoreIndexWithCollationForRegex: 1
},
command: {
aggregate: 'embedded_movies',
pipeline: [
{
'$vectorSearch': {
index: 'vector_index',
path: 'plot_embedding_voyage_3_large',
queryVector: [
-0.034731735, 0.008558298, -0.0153717, -0.029912498, 0.011549547,
...,
-0.006688767, 0.047527634, 0.040714234
],
numCandidates: 150,
limit: 10
}
}
],
cursor: {},
'$db': 'sample_mflix'
},
ok: 1,
'$clusterTime': {
clusterTime: Timestamp({ t: 1759342175, i: 1 }),
signature: {
hash: Binary.createFromBase64('AZZrjVPfyyBofyQq/gzs9UBL+/Q=', 0),
keyId: Long('7553982574624768005')
}
},
operationTime: Timestamp({ t: 1759342175, i: 1 })
}
db.embedded_movies.explain("executionStats").aggregate([
{
"$vectorSearch": {
"index": "vector_index",
"path": "plot_embedding_voyage_3_large",
"queryVector": QUERY_EMBEDDING,
"exact": true,
"limit": 10
}
}
])
{
explainVersion: '1',
stages: [
{
'$vectorSearch': {
index: 'vector_index',
path: 'plot_embedding_voyage_3_large',
queryVector: 'redacted',
exact: true,
limit: 10,
explain: {
query: {
type: 'ExactVectorSearchQuery',
args: {
field: '$type:knnVector/plot_embedding_voyage_3_large',
similarityFunction: 'dotProduct',
filter: {
type: 'DefaultQuery',
args: { queryType: 'FieldExistsQuery' },
stats: {
context: {
millisElapsed: 0.037129,
invocationCounts: {
createWeight: Long('1'),
createScorer: Long('4')
}
},
match: {
millisElapsed: 1.128957,
invocationCounts: { nextDoc: Long('3405') }
},
score: { millisElapsed: 0 }
}
}
},
stats: {
context: {
millisElapsed: 0.061268,
invocationCounts: { createWeight: Long('1'), createScorer: Long('4') }
},
match: {
millisElapsed: 2.531393,
invocationCounts: { nextDoc: Long('3405') }
},
score: {
millisElapsed: 7.956341,
invocationCounts: {
score: Long('3403'),
setMinCompetitiveScore: Long('63')
}
}
}
},
collectors: {
allCollectorStats: {
millisElapsed: 10.004281,
invocationCounts: {
collect: Long('3403'),
competitiveIterator: Long('2'),
setScorer: Long('2')
}
}
},
metadata: {
mongotVersion: '1.54.0',
mongotHostName: '<hostname>.mongodb.net',
indexName: 'vector_index',
lucene: { totalSegments: 2, totalDocs: 3483 }
},
resourceUsage: {
majorFaults: Long('0'),
minorFaults: Long('0'),
userTimeMs: Long('0'),
systemTimeMs: Long('0'),
maxReportingThreads: 1,
numBatches: 1
}
}
},
nReturned: Long('10'),
executionTimeMillisEstimate: Long('25')
},
{
'$_internalSearchIdLookup': {
limit: Long('10'),
subPipeline: [
{ '$match': { _id: { '$eq': '_id placeholder' } } }
],
totalDocsExamined: Long('10'),
totalKeysExamined: Long('10'),
numDocsFilteredByIdLookup: Long('0')
},
nReturned: Long('10'),
executionTimeMillisEstimate: Long('26')
}
],
queryShapeHash: '2E39BED257F2B59D3F8652E1A81A18B1140602C4E253DED9FE208D584EA00083',
serverInfo: {
host: '<hostname>.mongodb.net',
port: 27017,
version: '8.2.1-rc1',
gitVersion: '3312bdcf28aa65f5930005e21c2cb130f648b8c3'
},
serverParameters: {
internalQueryFacetBufferSizeBytes: 104857600,
internalQueryFacetMaxOutputDocSizeBytes: 104857600,
internalLookupStageIntermediateDocumentMaxSizeBytes: 104857600,
internalDocumentSourceGroupMaxMemoryBytes: 104857600,
internalQueryMaxBlockingSortMemoryUsageBytes: 104857600,
internalQueryProhibitBlockingMergeOnMongoS: 0,
internalQueryMaxAddToSetBytes: 104857600,
internalDocumentSourceSetWindowFieldsMaxMemoryBytes: 104857600,
internalQueryFrameworkControl: 'trySbeRestricted',
internalQueryPlannerIgnoreIndexWithCollationForRegex: 1
},
command: {
aggregate: 'embedded_movies',
pipeline: [
{
'$vectorSearch': {
index: 'vector_index',
path: 'plot_embedding_voyage_3_large',
queryVector: [
-0.034731735, 0.008558298, -0.0153717, -0.029912498, 0.011549547,
...,
-0.006688767, 0.047527634, 0.040714234
],
exact: true,
limit: 10
}
}
],
cursor: {},
'$db': 'sample_mflix'
},
ok: 1,
'$clusterTime': {
clusterTime: Timestamp({ t: 1759342255, i: 1 }),
signature: {
hash: Binary.createFromBase64('sHuAxj9o8MbGe4iRz0Pv1PSi+UY=', 0),
keyId: Long('7553982574624768005')
}
},
operationTime: Timestamp({ t: 1759342255, i: 1 })
}
db.embedded_movies.explain("executionStats").aggregate([
{
"$vectorSearch": {
"index": "vector_index",
"path": "plot_embedding_voyage_3_large",
"queryVector": QUERY_EMBEDDING,
"numCandidates": 150,
"limit": 10,
"explainOptions": {
"traceDocumentIds": [
ObjectId('573a13d8f29313caabda6557'), ObjectId('573a1398f29313caabce98d9'), ObjectId('573a1391f29313caabcd8319'), ObjectId('573a1398f29313caabceb500'), ObjectId('573a1397f29313caabce780e')
]
}
}
}
])
{
explainVersion: '1',
stages: [
{
'$vectorSearch': {
index: 'vector_index',
path: 'plot_embedding_voyage_3_large',
queryVector: 'redacted',
numCandidates: 150,
limit: 10,
explainOptions: {
traceDocumentIds: [
ObjectId('573a13d8f29313caabda6557'),
ObjectId('573a1398f29313caabce98d9'),
ObjectId('573a1391f29313caabcd8319'),
ObjectId('573a1398f29313caabceb500'),
ObjectId('573a1397f29313caabce780e')
]
},
explain: {
query: {
type: 'WrappedKnnQuery',
args: {
query: [
{
type: 'InstrumentableKnnFloatVectorQuery',
args: {
field: '$type:knnVector/plot_embedding_voyage_3_large',
k: 150
},
stats: {
context: { millisElapsed: 0 },
match: { millisElapsed: 0 },
score: { millisElapsed: 0 }
}
},
{
type: 'DocAndScoreQuery',
args: {},
stats: {
context: {
millisElapsed: 0.010987,
invocationCounts: {
createWeight: Long('1'),
createScorer: Long('4')
}
},
match: {
millisElapsed: 0.009977,
invocationCounts: { nextDoc: Long('152') }
},
score: {
millisElapsed: 0.018875,
invocationCounts: {
score: Long('150'),
setMinCompetitiveScore: Long('26')
}
}
}
}
]
},
stats: {
context: {
millisElapsed: 7.55246,
invocationCounts: {
vectorExecution: Long('1'),
createWeight: Long('1'),
createScorer: Long('4')
}
},
match: {
millisElapsed: 0.009977,
invocationCounts: { nextDoc: Long('152') }
},
score: {
millisElapsed: 0.018875,
invocationCounts: {
score: Long('150'),
setMinCompetitiveScore: Long('26')
}
}
}
},
collectors: {
allCollectorStats: {
millisElapsed: 0.148807,
invocationCounts: {
collect: Long('150'),
competitiveIterator: Long('2'),
setScorer: Long('2')
}
}
},
metadata: {
mongotVersion: '1.54.0',
mongotHostName: '<hostname>.mongodb.net',
indexName: 'vector_index',
lucene: { totalSegments: 2, totalDocs: 3483 }
},
resourceUsage: {
majorFaults: Long('0'),
minorFaults: Long('0'),
userTimeMs: Long('0'),
systemTimeMs: Long('0'),
maxReportingThreads: 1,
numBatches: 1
},
vectorTracing: [
{
documentId: ObjectId('573a1391f29313caabcd8319'),
visited: false,
luceneSegment: '_0'
},
{
documentId: ObjectId('573a1397f29313caabce780e'),
visited: true,
vectorSearchScore: 0.7469133734703064,
luceneSegment: '_0'
},
{
documentId: ObjectId('573a1398f29313caabce98d9'),
visited: false,
luceneSegment: '_0'
},
{
documentId: ObjectId('573a1398f29313caabceb500'),
visited: true,
vectorSearchScore: 0.7521393895149231,
luceneSegment: '_0'
},
{
documentId: ObjectId('573a13d8f29313caabda6557'),
visited: true,
vectorSearchScore: 0.7710106372833252,
luceneSegment: '_1'
}
],
luceneVectorSegmentStats: [
{
id: '_1',
executionType: 'Approximate',
docCount: 1531,
approximateStage: { millisElapsed: 2.73042 }
},
{
id: '_0',
executionType: 'Approximate',
docCount: 1952,
approximateStage: { millisElapsed: 4.136979 }
}
]
}
},
nReturned: Long('10'),
executionTimeMillisEstimate: Long('21')
},
{
'$_internalSearchIdLookup': {
limit: Long('10'),
subPipeline: [
{ '$match': { _id: { '$eq': '_id placeholder' } } }
],
totalDocsExamined: Long('10'),
totalKeysExamined: Long('10'),
numDocsFilteredByIdLookup: Long('0')
},
nReturned: Long('10'),
executionTimeMillisEstimate: Long('22')
}
],
queryShapeHash: '2E39BED257F2B59D3F8652E1A81A18B1140602C4E253DED9FE208D584EA00083',
serverInfo: {
host: '<hostname>.mongodb.net',
port: 27017,
version: '8.2.1-rc1',
gitVersion: '3312bdcf28aa65f5930005e21c2cb130f648b8c3'
},
serverParameters: {
internalQueryFacetBufferSizeBytes: 104857600,
internalQueryFacetMaxOutputDocSizeBytes: 104857600,
internalLookupStageIntermediateDocumentMaxSizeBytes: 104857600,
internalDocumentSourceGroupMaxMemoryBytes: 104857600,
internalQueryMaxBlockingSortMemoryUsageBytes: 104857600,
internalQueryProhibitBlockingMergeOnMongoS: 0,
internalQueryMaxAddToSetBytes: 104857600,
internalDocumentSourceSetWindowFieldsMaxMemoryBytes: 104857600,
internalQueryFrameworkControl: 'trySbeRestricted',
internalQueryPlannerIgnoreIndexWithCollationForRegex: 1
},
command: {
aggregate: 'embedded_movies',
pipeline: [
{
'$vectorSearch': {
index: 'vector_index',
path: 'plot_embedding_voyage_3_large',
queryVector: [
-0.034731735, 0.008558298, -0.0153717, -0.029912498, 0.011549547,
...,
-0.006688767, 0.047527634, 0.040714234
],
numCandidates: 150,
limit: 10,
explainOptions: {
traceDocumentIds: [
ObjectId('573a13d8f29313caabda6557'),
ObjectId('573a1398f29313caabce98d9'),
ObjectId('573a1391f29313caabcd8319'),
ObjectId('573a1398f29313caabceb500'),
ObjectId('573a1397f29313caabce780e')
]
}
}
}
],
cursor: {},
'$db': 'sample_mflix'
},
ok: 1,
'$clusterTime': {
clusterTime: Timestamp({ t: 1759343038, i: 1 }),
signature: {
hash: Binary.createFromBase64('E3FSIwLHavtFVMsmuqJM5reQc4I=', 0),
keyId: Long('7553982574624768005')
}
},
operationTime: Timestamp({ t: 1759343038, i: 1 })
}

돌아가기

쿼리 참조

이 페이지의 내용