@@ -68,6 +68,16 @@ describe('boolean search logic', () => {
68
68
doc = await insert . batches . next ( )
69
69
expect ( doc [ 0 ] . title ) . to . equal ( 'doc B' )
70
70
71
+ const docC = {
72
+ title : 'doc C' ,
73
+ text_en :
74
+ 'random configuration letters and numbers 1323 string non-matching assortments' ,
75
+ }
76
+
77
+ insert = await db . query ( aql `INSERT ${ docC } INTO ${ collection } RETURN NEW` )
78
+ doc = await insert . batches . next ( )
79
+ expect ( doc [ 0 ] . title ) . to . equal ( 'doc C' )
80
+
71
81
const wait = ( t : number ) => new Promise ( ( keep ) => setTimeout ( keep , t ) )
72
82
await wait ( 1600 )
73
83
@@ -112,15 +122,15 @@ describe('boolean search logic', () => {
112
122
let cursor = await db . query ( aqlQuery )
113
123
114
124
let result = await cursor . batches . all ( )
115
- expect ( result [ 0 ] ) . to . have . length ( 2 )
125
+ expect ( result [ 0 ] ) . to . have . length ( 3 )
116
126
117
127
// pass multiple keys
118
128
query . key = [ 'text_en' , 'text_es' ]
119
129
aqlQuery = buildAQL ( query )
120
130
cursor = await db . query ( aqlQuery )
121
131
122
132
result = await cursor . batches . all ( )
123
- expect ( result [ 0 ] ) . to . have . length ( 2 )
133
+ expect ( result [ 0 ] ) . to . have . length ( 3 )
124
134
} )
125
135
} )
126
136
@@ -278,7 +288,7 @@ describe('boolean search logic', () => {
278
288
expect ( result [ 0 ] . title ) . to . equal ( 'doc B' )
279
289
280
290
/* should bring back 0 document */
281
- query . terms = 'random nonexistent stuff'
291
+ query . terms = 'nonexistent stuff'
282
292
aqlQuery = buildAQL ( query )
283
293
cursor = await db . query ( aqlQuery )
284
294
@@ -393,7 +403,7 @@ describe('boolean search logic', () => {
393
403
cursor = await db . query ( aqlQuery )
394
404
395
405
result = await cursor . all ( )
396
- expect ( result ) . to . have . length ( 1 )
406
+ expect ( result ) . to . have . length ( 2 )
397
407
expect ( result [ 0 ] . title ) . to . equal ( 'doc A' )
398
408
399
409
/* should bring back 0 results */
@@ -426,7 +436,7 @@ describe('boolean search logic', () => {
426
436
let cursor = await db . query ( aqlQuery )
427
437
428
438
let result = await cursor . all ( )
429
- expect ( result ) . to . have . length ( 1 )
439
+ expect ( result ) . to . have . length ( 2 )
430
440
/* should exclude doc B */
431
441
expect ( result [ 0 ] . title ) . to . equal ( 'doc A' )
432
442
@@ -451,4 +461,32 @@ describe('boolean search logic', () => {
451
461
expect ( result [ 0 ] . title ) . to . equal ( 'doc B' )
452
462
} )
453
463
} )
464
+
465
+ describe ( 'boost' , ( ) => {
466
+ it . only ( 'boosts results that include optional terms' , async ( ) => {
467
+ const query = {
468
+ view : view . name ,
469
+ collections : [
470
+ {
471
+ name : collectionName ,
472
+ analyzer : 'text_en' ,
473
+ } ,
474
+ {
475
+ name : collectionName ,
476
+ analyzer : 'text_es' ,
477
+ } ,
478
+ ] ,
479
+ terms : ' +string configuration Alice assortments' ,
480
+ key : [ 'text_en' , 'text_es' ] ,
481
+ }
482
+
483
+ let aqlQuery = buildAQL ( query )
484
+ let cursor = await db . query ( aqlQuery )
485
+
486
+ let result = await cursor . all ( )
487
+ expect ( result ) . to . have . length ( 2 )
488
+ // "string" is in documents B and C, while "configuration" and "assortments" are only in C
489
+ expect ( result [ 0 ] . title ) . to . equal ( 'doc C' )
490
+ } )
491
+ } )
454
492
} )
0 commit comments