Skip to content

Commit 10577eb

Browse files
GODRIVER-3359 Sync with master branch
1 parent 9245e42 commit 10577eb

10 files changed

+257
-41
lines changed

testdata/index-management/createSearchIndex.json

Lines changed: 81 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,17 @@
2828
],
2929
"runOnRequirements": [
3030
{
31-
"minServerVersion": "7.0.0",
31+
"minServerVersion": "7.0.5",
32+
"maxServerVersion": "7.0.99",
33+
"topologies": [
34+
"replicaset",
35+
"load-balanced",
36+
"sharded"
37+
],
38+
"serverless": "forbid"
39+
},
40+
{
41+
"minServerVersion": "7.2.0",
3242
"topologies": [
3343
"replicaset",
3444
"load-balanced",
@@ -50,12 +60,13 @@
5060
"mappings": {
5161
"dynamic": true
5262
}
53-
}
63+
},
64+
"type": "search"
5465
}
5566
},
5667
"expectError": {
5768
"isError": true,
58-
"errorContains": "Search index commands are only supported with Atlas"
69+
"errorContains": "Atlas"
5970
}
6071
}
6172
],
@@ -73,7 +84,8 @@
7384
"mappings": {
7485
"dynamic": true
7586
}
76-
}
87+
},
88+
"type": "search"
7789
}
7890
],
7991
"$db": "database0"
@@ -97,12 +109,13 @@
97109
"dynamic": true
98110
}
99111
},
100-
"name": "test index"
112+
"name": "test index",
113+
"type": "search"
101114
}
102115
},
103116
"expectError": {
104117
"isError": true,
105-
"errorContains": "Search index commands are only supported with Atlas"
118+
"errorContains": "Atlas"
106119
}
107120
}
108121
],
@@ -121,7 +134,68 @@
121134
"dynamic": true
122135
}
123136
},
124-
"name": "test index"
137+
"name": "test index",
138+
"type": "search"
139+
}
140+
],
141+
"$db": "database0"
142+
}
143+
}
144+
}
145+
]
146+
}
147+
]
148+
},
149+
{
150+
"description": "create a vector search index",
151+
"operations": [
152+
{
153+
"name": "createSearchIndex",
154+
"object": "collection0",
155+
"arguments": {
156+
"model": {
157+
"definition": {
158+
"fields": [
159+
{
160+
"type": "vector",
161+
"path": "plot_embedding",
162+
"numDimensions": 1536,
163+
"similarity": "euclidean"
164+
}
165+
]
166+
},
167+
"name": "test index",
168+
"type": "vectorSearch"
169+
}
170+
},
171+
"expectError": {
172+
"isError": true,
173+
"errorContains": "Atlas"
174+
}
175+
}
176+
],
177+
"expectEvents": [
178+
{
179+
"client": "client0",
180+
"events": [
181+
{
182+
"commandStartedEvent": {
183+
"command": {
184+
"createSearchIndexes": "collection0",
185+
"indexes": [
186+
{
187+
"definition": {
188+
"fields": [
189+
{
190+
"type": "vector",
191+
"path": "plot_embedding",
192+
"numDimensions": 1536,
193+
"similarity": "euclidean"
194+
}
195+
]
196+
},
197+
"name": "test index",
198+
"type": "vectorSearch"
125199
}
126200
],
127201
"$db": "database0"

testdata/index-management/createSearchIndex.yml

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ createEntities:
1616
collectionName: *collection0
1717

1818
runOnRequirements:
19-
- minServerVersion: "7.0.0"
19+
# Skip server versions without fix of SERVER-83107 to avoid error message "BSON field 'createSearchIndexes.indexes.type' is an unknown field."
20+
# SERVER-83107 was not backported to 7.1.
21+
- minServerVersion: "7.0.5"
22+
maxServerVersion: "7.0.99"
23+
topologies: [ replicaset, load-balanced, sharded ]
24+
serverless: forbid
25+
- minServerVersion: "7.2.0"
2026
topologies: [ replicaset, load-balanced, sharded ]
2127
serverless: forbid
2228

@@ -26,37 +32,61 @@ tests:
2632
- name: createSearchIndex
2733
object: *collection0
2834
arguments:
29-
model: { definition: &definition { mappings: { dynamic: true } } }
35+
model: { definition: &definition { mappings: { dynamic: true } } , type: 'search' }
3036
expectError:
3137
# This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
3238
# that the driver constructs and sends the correct command.
39+
# The expected error message was changed in SERVER-83003. Check for the substring "Atlas" shared by both error messages.
3340
isError: true
34-
errorContains: Search index commands are only supported with Atlas
41+
errorContains: Atlas
3542
expectEvents:
3643
- client: *client0
3744
events:
3845
- commandStartedEvent:
3946
command:
4047
createSearchIndexes: *collection0
41-
indexes: [ { definition: *definition } ]
48+
indexes: [ { definition: *definition, type: 'search'} ]
4249
$db: *database0
4350

4451
- description: "name provided for an index definition"
4552
operations:
4653
- name: createSearchIndex
4754
object: *collection0
4855
arguments:
49-
model: { definition: &definition { mappings: { dynamic: true } } , name: 'test index' }
56+
model: { definition: &definition { mappings: { dynamic: true } } , name: 'test index', type: 'search' }
57+
expectError:
58+
# This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
59+
# that the driver constructs and sends the correct command.
60+
# The expected error message was changed in SERVER-83003. Check for the substring "Atlas" shared by both error messages.
61+
isError: true
62+
errorContains: Atlas
63+
expectEvents:
64+
- client: *client0
65+
events:
66+
- commandStartedEvent:
67+
command:
68+
createSearchIndexes: *collection0
69+
indexes: [ { definition: *definition, name: 'test index', type: 'search' } ]
70+
$db: *database0
71+
72+
- description: "create a vector search index"
73+
operations:
74+
- name: createSearchIndex
75+
object: *collection0
76+
arguments:
77+
model: { definition: &definition { fields: [ {"type": "vector", "path": "plot_embedding", "numDimensions": 1536, "similarity": "euclidean"} ] }
78+
, name: 'test index', type: 'vectorSearch' }
5079
expectError:
5180
# This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
5281
# that the driver constructs and sends the correct command.
82+
# The expected error message was changed in SERVER-83003. Check for the substring "Atlas" shared by both error messages.
5383
isError: true
54-
errorContains: Search index commands are only supported with Atlas
84+
errorContains: Atlas
5585
expectEvents:
5686
- client: *client0
5787
events:
5888
- commandStartedEvent:
5989
command:
6090
createSearchIndexes: *collection0
61-
indexes: [ { definition: *definition, name: 'test index' } ]
91+
indexes: [ { definition: *definition, name: 'test index', type: 'vectorSearch' } ]
6292
$db: *database0

testdata/index-management/createSearchIndexes.json

Lines changed: 84 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,17 @@
2828
],
2929
"runOnRequirements": [
3030
{
31-
"minServerVersion": "7.0.0",
31+
"minServerVersion": "7.0.5",
32+
"maxServerVersion": "7.0.99",
33+
"topologies": [
34+
"replicaset",
35+
"load-balanced",
36+
"sharded"
37+
],
38+
"serverless": "forbid"
39+
},
40+
{
41+
"minServerVersion": "7.2.0",
3242
"topologies": [
3343
"replicaset",
3444
"load-balanced",
@@ -49,7 +59,7 @@
4959
},
5060
"expectError": {
5161
"isError": true,
52-
"errorContains": "Search index commands are only supported with Atlas"
62+
"errorContains": "Atlas"
5363
}
5464
}
5565
],
@@ -83,13 +93,14 @@
8393
"mappings": {
8494
"dynamic": true
8595
}
86-
}
96+
},
97+
"type": "search"
8798
}
8899
]
89100
},
90101
"expectError": {
91102
"isError": true,
92-
"errorContains": "Search index commands are only supported with Atlas"
103+
"errorContains": "Atlas"
93104
}
94105
}
95106
],
@@ -107,7 +118,8 @@
107118
"mappings": {
108119
"dynamic": true
109120
}
110-
}
121+
},
122+
"type": "search"
111123
}
112124
],
113125
"$db": "database0"
@@ -132,13 +144,14 @@
132144
"dynamic": true
133145
}
134146
},
135-
"name": "test index"
147+
"name": "test index",
148+
"type": "search"
136149
}
137150
]
138151
},
139152
"expectError": {
140153
"isError": true,
141-
"errorContains": "Search index commands are only supported with Atlas"
154+
"errorContains": "Atlas"
142155
}
143156
}
144157
],
@@ -157,7 +170,70 @@
157170
"dynamic": true
158171
}
159172
},
160-
"name": "test index"
173+
"name": "test index",
174+
"type": "search"
175+
}
176+
],
177+
"$db": "database0"
178+
}
179+
}
180+
}
181+
]
182+
}
183+
]
184+
},
185+
{
186+
"description": "create a vector search index",
187+
"operations": [
188+
{
189+
"name": "createSearchIndexes",
190+
"object": "collection0",
191+
"arguments": {
192+
"models": [
193+
{
194+
"definition": {
195+
"fields": [
196+
{
197+
"type": "vector",
198+
"path": "plot_embedding",
199+
"numDimensions": 1536,
200+
"similarity": "euclidean"
201+
}
202+
]
203+
},
204+
"name": "test index",
205+
"type": "vectorSearch"
206+
}
207+
]
208+
},
209+
"expectError": {
210+
"isError": true,
211+
"errorContains": "Atlas"
212+
}
213+
}
214+
],
215+
"expectEvents": [
216+
{
217+
"client": "client0",
218+
"events": [
219+
{
220+
"commandStartedEvent": {
221+
"command": {
222+
"createSearchIndexes": "collection0",
223+
"indexes": [
224+
{
225+
"definition": {
226+
"fields": [
227+
{
228+
"type": "vector",
229+
"path": "plot_embedding",
230+
"numDimensions": 1536,
231+
"similarity": "euclidean"
232+
}
233+
]
234+
},
235+
"name": "test index",
236+
"type": "vectorSearch"
161237
}
162238
],
163239
"$db": "database0"

0 commit comments

Comments
 (0)