Skip to content

Commit ccb1b63

Browse files
committed
edit: boost test passed
1 parent 3434c7e commit ccb1b63

File tree

1 file changed

+43
-5
lines changed

1 file changed

+43
-5
lines changed

tests/bool.ts

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ describe('boolean search logic', () => {
6868
doc = await insert.batches.next()
6969
expect(doc[0].title).to.equal('doc B')
7070

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+
7181
const wait = (t: number) => new Promise((keep) => setTimeout(keep, t))
7282
await wait(1600)
7383

@@ -112,15 +122,15 @@ describe('boolean search logic', () => {
112122
let cursor = await db.query(aqlQuery)
113123

114124
let result = await cursor.batches.all()
115-
expect(result[0]).to.have.length(2)
125+
expect(result[0]).to.have.length(3)
116126

117127
// pass multiple keys
118128
query.key = ['text_en', 'text_es']
119129
aqlQuery = buildAQL(query)
120130
cursor = await db.query(aqlQuery)
121131

122132
result = await cursor.batches.all()
123-
expect(result[0]).to.have.length(2)
133+
expect(result[0]).to.have.length(3)
124134
})
125135
})
126136

@@ -278,7 +288,7 @@ describe('boolean search logic', () => {
278288
expect(result[0].title).to.equal('doc B')
279289

280290
/* should bring back 0 document */
281-
query.terms = 'random nonexistent stuff'
291+
query.terms = 'nonexistent stuff'
282292
aqlQuery = buildAQL(query)
283293
cursor = await db.query(aqlQuery)
284294

@@ -393,7 +403,7 @@ describe('boolean search logic', () => {
393403
cursor = await db.query(aqlQuery)
394404

395405
result = await cursor.all()
396-
expect(result).to.have.length(1)
406+
expect(result).to.have.length(2)
397407
expect(result[0].title).to.equal('doc A')
398408

399409
/* should bring back 0 results */
@@ -426,7 +436,7 @@ describe('boolean search logic', () => {
426436
let cursor = await db.query(aqlQuery)
427437

428438
let result = await cursor.all()
429-
expect(result).to.have.length(1)
439+
expect(result).to.have.length(2)
430440
/* should exclude doc B */
431441
expect(result[0].title).to.equal('doc A')
432442

@@ -451,4 +461,32 @@ describe('boolean search logic', () => {
451461
expect(result[0].title).to.equal('doc B')
452462
})
453463
})
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+
})
454492
})

0 commit comments

Comments
 (0)