Skip to content

Commit 9a24fcc

Browse files
authored
feat(relevance): merge all the query rules (#194)
We want to boost packages which have either the name, the concatenated name or the split name. After that boosting has happened, there can still be other relevance at play. Queries to test: * reactnative * react native * react-native * absolute path * absolutepath * absolute-path * ract * boostrap * preact Since this is not enabled yet the flow I'm seeing is this: 1. merge this PR directly 2. make a replica after it's completely done 3. add the query rule to that replica 4. test out the performance on that replica 5. a second PR to enable the Query Rule
1 parent 74f4ecd commit 9a24fcc

File tree

5 files changed

+38
-6
lines changed

5 files changed

+38
-6
lines changed

src/__tests__/__snapshots__/config.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ Object {
2020
],
2121
},
2222
},
23-
"description": "promote exact matches",
24-
"objectID": "promote-exact",
23+
"description": "promote exact matches (old, delete me in a next PR)",
24+
"objectID": "promote-exact-old",
2525
},
2626
],
2727
"indexSettings": Object {

src/__tests__/__snapshots__/formatPkg.test.js.snap

Lines changed: 16 additions & 1 deletion
Large diffs are not rendered by default.

src/__tests__/formatPkg.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ it('truncates long readmes', () => {
2424
formatted.readme.length - truncatedEnding.length
2525
);
2626

27-
expect(formatted.readme).toHaveLength(451140);
27+
expect(formatted.readme).toHaveLength(451220);
2828
expect(ending).toBe(truncatedEnding);
2929

3030
formatted.lastCrawl = '<!-- date replaced -->';

src/config.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ const defaultConfig = {
6161
],
6262
indexRules: [
6363
{
64-
objectID: 'promote-exact',
65-
description: 'promote exact matches',
64+
objectID: 'promote-exact-old',
65+
description: 'promote exact matches (old, delete me in a next PR)',
6666
condition: {
6767
pattern: '{facet:_searchInternal.concatenatedName}',
6868
anchoring: 'is',
@@ -73,6 +73,21 @@ const defaultConfig = {
7373
},
7474
},
7575
},
76+
// not yet enabled, but to be done in a replica after this is merged and
77+
// in production
78+
// {
79+
// objectID: 'promote-exact',
80+
// description: 'promote exact matches',
81+
// condition: {
82+
// pattern: '{facet:_searchInternal.alternativeNames}',
83+
// anchoring: 'is',
84+
// },
85+
// consequence: {
86+
// params: {
87+
// automaticOptionalFacetFilters: ['_searchInternal.alternativeNames'],
88+
// },
89+
// },
90+
// },
7691
],
7792
};
7893

src/formatPkg.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export default function formatPkg(pkg) {
5858
const dependencies = cleaned.dependencies || {};
5959
const devDependencies = cleaned.devDependencies || {};
6060
const concatenatedName = cleaned.name.replace(/[-/@_.]+/g, '');
61+
const splitName = cleaned.name.replace(/[-/@_.]+/g, ' ');
6162

6263
const tags = pkg['dist-tags'];
6364

@@ -93,6 +94,7 @@ export default function formatPkg(pkg) {
9394
lastCrawl: new Date().toISOString(),
9495
_searchInternal: {
9596
concatenatedName,
97+
alternativeNames: [concatenatedName, splitName, name],
9698
},
9799
};
98100

0 commit comments

Comments
 (0)