feat(core): tuning for better search (#7713)

This commit is contained in:
EYHN
2024-08-05 02:29:50 +00:00
parent ad26102815
commit f108b95704
3 changed files with 3 additions and 2 deletions

View File

@@ -6,4 +6,5 @@ test('bm25', () => {
expect(bm25(1, 1, 10, 10, 15)).toEqual(3.2792079793859643); expect(bm25(1, 1, 10, 10, 15)).toEqual(3.2792079793859643);
expect(bm25(2, 1, 10, 10, 15) > bm25(1, 1, 10, 10, 15)).toBeTruthy(); expect(bm25(2, 1, 10, 10, 15) > bm25(1, 1, 10, 10, 15)).toBeTruthy();
expect(bm25(1, 1, 10, 10, 15) > bm25(2, 1, 10, 100, 15)).toBeTruthy(); expect(bm25(1, 1, 10, 10, 15) > bm25(2, 1, 10, 100, 15)).toBeTruthy();
expect(bm25(1, 1, 10, 10, 15) > bm25(1, 1, 10, 100, 15)).toBeTruthy();
}); });

View File

@@ -57,6 +57,6 @@ export const bm25 = (
invDocFreq * invDocFreq *
(d + (d +
(termFreq * (k + 1)) / (termFreq * (k + 1)) /
(termFreq + k * (1 - b + (b * fieldLength) / avgFieldLength))) (termFreq + k * (1 - b + b * (fieldLength / avgFieldLength))))
); );
}; };

View File

@@ -146,7 +146,7 @@ export class DocsSearchService extends Service {
}, },
{ {
type: 'boost', type: 'boost',
boost: 100, boost: 1.5,
query: { query: {
type: 'match', type: 'match',
field: 'flavour', field: 'flavour',