@@ -218,6 +218,92 @@ Hint: It might not be working because maybe you're not up to date with the Meili
218218 expect ( documents . results . length ) . toEqual ( dataset . length ) ;
219219 } ) ;
220220
221+ test ( `${ permission } key: Get documents with retrieveVectors to true` , async ( ) => {
222+ const client = await getClient ( permission ) ;
223+ const adminKey = await getKey ( 'Admin' ) ;
224+
225+ await fetch ( `${ HOST } /experimental-features` , {
226+ body : JSON . stringify ( { vectorStore : true } ) ,
227+ headers : {
228+ Authorization : `Bearer ${ adminKey } ` ,
229+ 'Content-Type' : 'application/json' ,
230+ } ,
231+ method : 'PATCH' ,
232+ } ) ;
233+
234+ const { taskUid } = await client
235+ . index ( indexPk . uid )
236+ . addDocuments ( dataset ) ;
237+ await client . index ( indexPk . uid ) . waitForTask ( taskUid ) ;
238+
239+ // Get documents with POST
240+ const documentsPost = await client
241+ . index ( indexPk . uid )
242+ . getDocuments < Book > ( { retrieveVectors : true } ) ;
243+
244+ expect ( documentsPost . results . length ) . toEqual ( dataset . length ) ;
245+ expect ( documentsPost . results [ 0 ] ) . toHaveProperty ( '_vectors' ) ;
246+
247+ // Get documents with GET
248+ const res = await fetch (
249+ `${ HOST } /indexes/${ indexPk . uid } /documents?retrieveVectors=true` ,
250+ {
251+ headers : {
252+ Authorization : `Bearer ${ adminKey } ` ,
253+ 'Content-Type' : 'application/json' ,
254+ } ,
255+ method : 'GET' ,
256+ } ,
257+ ) ;
258+ const documentsGet = await res . json ( ) ;
259+
260+ expect ( documentsGet . results . length ) . toEqual ( dataset . length ) ;
261+ expect ( documentsGet . results [ 0 ] ) . toHaveProperty ( '_vectors' ) ;
262+ } ) ;
263+
264+ test ( `${ permission } key: Get documents without retrieveVectors` , async ( ) => {
265+ const client = await getClient ( permission ) ;
266+ const adminKey = await getKey ( 'Admin' ) ;
267+
268+ await fetch ( `${ HOST } /experimental-features` , {
269+ body : JSON . stringify ( { vectorStore : true } ) ,
270+ headers : {
271+ Authorization : `Bearer ${ adminKey } ` ,
272+ 'Content-Type' : 'application/json' ,
273+ } ,
274+ method : 'PATCH' ,
275+ } ) ;
276+
277+ const { taskUid } = await client
278+ . index ( indexPk . uid )
279+ . addDocuments ( dataset ) ;
280+ await client . index ( indexPk . uid ) . waitForTask ( taskUid ) ;
281+
282+ // Get documents with POST
283+ const documentsPost = await client
284+ . index ( indexPk . uid )
285+ . getDocuments < Book > ( ) ;
286+
287+ expect ( documentsPost . results . length ) . toEqual ( dataset . length ) ;
288+ expect ( documentsPost . results [ 0 ] ) . not . toHaveProperty ( '_vectors' ) ;
289+
290+ // Get documents with GET
291+ const res = await fetch (
292+ `${ HOST } /indexes/${ indexPk . uid } /documents?retrieveVectors=false` ,
293+ {
294+ headers : {
295+ Authorization : `Bearer ${ adminKey } ` ,
296+ 'Content-Type' : 'application/json' ,
297+ } ,
298+ method : 'GET' ,
299+ } ,
300+ ) ;
301+ const documentsGet = await res . json ( ) ;
302+
303+ expect ( documentsGet . results . length ) . toEqual ( dataset . length ) ;
304+ expect ( documentsGet . results [ 0 ] ) . not . toHaveProperty ( '_vectors' ) ;
305+ } ) ;
306+
221307 test ( `${ permission } key: Replace documents from index that has NO primary key` , async ( ) => {
222308 const client = await getClient ( permission ) ;
223309 const { taskUid : addDocTask } = await client
0 commit comments