@@ -31,8 +31,7 @@ const fullTextHelper = () => {
31
31
const request = {
32
32
method : "POST" ,
33
33
body : {
34
- subject : subjects [ i ] ,
35
- comment : subjects [ i ] ,
34
+ subject : subjects [ i ]
36
35
} ,
37
36
path : "/1/classes/TestObject"
38
37
} ;
@@ -281,83 +280,42 @@ describe('Parse.Query Full Text Search testing', () => {
281
280
} ) ;
282
281
283
282
describe_only_db ( 'mongo' ) ( 'Parse.Query Full Text Search testing' , ( ) => {
284
- it ( 'fullTextSearch: does not create text index if compound index exist' , ( done ) => {
285
- fullTextHelper ( ) . then ( ( ) => {
286
- return databaseAdapter . dropAllIndexes ( 'TestObject' ) ;
287
- } ) . then ( ( ) => {
288
- return databaseAdapter . getIndexes ( 'TestObject' ) ;
289
- } ) . then ( ( indexes ) => {
290
- expect ( indexes . length ) . toEqual ( 1 ) ;
291
- return databaseAdapter . createIndex ( 'TestObject' , { subject : 'text' , comment : 'text' } ) ;
283
+ it ( 'fullTextSearch: $search, only one text index' , ( done ) => {
284
+ return reconfigureServer ( {
285
+ appId : 'test' ,
286
+ restAPIKey : 'test' ,
287
+ publicServerURL : 'http://localhost:8378/1' ,
288
+ databaseAdapter : new MongoStorageAdapter ( { uri : mongoURI } )
292
289
} ) . then ( ( ) => {
293
- return databaseAdapter . getIndexes ( 'TestObject' ) ;
294
- } ) . then ( ( indexes ) => {
295
- expect ( indexes . length ) . toEqual ( 2 ) ;
296
- const where = {
297
- subject : {
298
- $text : {
299
- $search : {
300
- $term : 'coffee'
301
- }
302
- }
303
- }
304
- } ;
305
290
return rp . post ( {
306
- url : 'http://localhost:8378/1/classes/TestObject' ,
307
- json : { where, '_method' : 'GET' } ,
291
+ url : 'http://localhost:8378/1/batch' ,
292
+ body : {
293
+ requests : [
294
+ {
295
+ method : "POST" ,
296
+ body : {
297
+ subject : "coffee is java"
298
+ } ,
299
+ path : "/1/classes/TestObject"
300
+ } ,
301
+ {
302
+ method : "POST" ,
303
+ body : {
304
+ subject : "java is coffee"
305
+ } ,
306
+ path : "/1/classes/TestObject"
307
+ }
308
+ ]
309
+ } ,
310
+ json : true ,
308
311
headers : {
309
312
'X-Parse-Application-Id' : 'test' ,
310
313
'X-Parse-REST-API-Key' : 'test'
311
314
}
312
315
} ) ;
313
- } ) . then ( ( resp ) => {
314
- expect ( resp . results . length ) . toEqual ( 3 ) ;
315
- return databaseAdapter . getIndexes ( 'TestObject' ) ;
316
- } ) . then ( ( indexes ) => {
317
- expect ( indexes . length ) . toEqual ( 2 ) ;
318
- rp . get ( {
319
- url : 'http://localhost:8378/1/schemas/TestObject' ,
320
- headers : {
321
- 'X-Parse-Application-Id' : 'test' ,
322
- 'X-Parse-Master-Key' : 'test' ,
323
- } ,
324
- json : true ,
325
- } , ( error , response , body ) => {
326
- expect ( body . indexes . _id_ ) . toBeDefined ( ) ;
327
- expect ( body . indexes . _id_ . _id ) . toEqual ( 1 ) ;
328
- expect ( body . indexes . subject_text_comment_text ) . toBeDefined ( ) ;
329
- expect ( body . indexes . subject_text_comment_text . subject ) . toEqual ( 'text' ) ;
330
- expect ( body . indexes . subject_text_comment_text . comment ) . toEqual ( 'text' ) ;
331
- done ( ) ;
332
- } ) ;
333
- } ) . catch ( done . fail ) ;
334
- } ) ;
335
-
336
- it ( 'fullTextSearch: does not create text index if schema compound index exist' , ( done ) => {
337
- fullTextHelper ( ) . then ( ( ) => {
338
- return databaseAdapter . dropAllIndexes ( 'TestObject' ) ;
339
316
} ) . then ( ( ) => {
340
- return databaseAdapter . getIndexes ( 'TestObject' ) ;
341
- } ) . then ( ( indexes ) => {
342
- expect ( indexes . length ) . toEqual ( 1 ) ;
343
- return rp . put ( {
344
- url : 'http://localhost:8378/1/schemas/TestObject' ,
345
- json : true ,
346
- headers : {
347
- 'X-Parse-Application-Id' : 'test' ,
348
- 'X-Parse-REST-API-Key' : 'test' ,
349
- 'X-Parse-Master-Key' : 'test' ,
350
- } ,
351
- body : {
352
- indexes : {
353
- text_test : { subject : 'text' , comment : 'text' } ,
354
- } ,
355
- } ,
356
- } ) ;
317
+ return databaseAdapter . createIndex ( 'TestObject' , { random : 'text' } ) ;
357
318
} ) . then ( ( ) => {
358
- return databaseAdapter . getIndexes ( 'TestObject' ) ;
359
- } ) . then ( ( indexes ) => {
360
- expect ( indexes . length ) . toEqual ( 2 ) ;
361
319
const where = {
362
320
subject : {
363
321
$text : {
@@ -376,26 +334,12 @@ describe_only_db('mongo')('Parse.Query Full Text Search testing', () => {
376
334
}
377
335
} ) ;
378
336
} ) . then ( ( resp ) => {
379
- expect ( resp . results . length ) . toEqual ( 3 ) ;
380
- return databaseAdapter . getIndexes ( 'TestObject' ) ;
381
- } ) . then ( ( indexes ) => {
382
- expect ( indexes . length ) . toEqual ( 2 ) ;
383
- rp . get ( {
384
- url : 'http://localhost:8378/1/schemas/TestObject' ,
385
- headers : {
386
- 'X-Parse-Application-Id' : 'test' ,
387
- 'X-Parse-Master-Key' : 'test' ,
388
- } ,
389
- json : true ,
390
- } , ( error , response , body ) => {
391
- expect ( body . indexes . _id_ ) . toBeDefined ( ) ;
392
- expect ( body . indexes . _id_ . _id ) . toEqual ( 1 ) ;
393
- expect ( body . indexes . text_test ) . toBeDefined ( ) ;
394
- expect ( body . indexes . text_test . subject ) . toEqual ( 'text' ) ;
395
- expect ( body . indexes . text_test . comment ) . toEqual ( 'text' ) ;
396
- done ( ) ;
397
- } ) ;
398
- } ) . catch ( done . fail ) ;
337
+ fail ( `Should not be more than one text index: ${ JSON . stringify ( resp ) } ` ) ;
338
+ done ( ) ;
339
+ } ) . catch ( ( err ) => {
340
+ expect ( err . error . code ) . toEqual ( Parse . Error . INTERNAL_SERVER_ERROR ) ;
341
+ done ( ) ;
342
+ } ) ;
399
343
} ) ;
400
344
401
345
it ( 'fullTextSearch: $diacriticSensitive - false' , ( done ) => {
0 commit comments