Skip to content

Commit

Permalink
feat(relevance): merge all the query rules (#194)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Haroenv authored May 4, 2018
1 parent 74f4ecd commit 9a24fcc
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/__tests__/__snapshots__/config.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Object {
],
},
},
"description": "promote exact matches",
"objectID": "promote-exact",
"description": "promote exact matches (old, delete me in a next PR)",
"objectID": "promote-exact-old",
},
],
"indexSettings": Object {
Expand Down
17 changes: 16 additions & 1 deletion src/__tests__/__snapshots__/formatPkg.test.js.snap

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/__tests__/formatPkg.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ it('truncates long readmes', () => {
formatted.readme.length - truncatedEnding.length
);

expect(formatted.readme).toHaveLength(451140);
expect(formatted.readme).toHaveLength(451220);
expect(ending).toBe(truncatedEnding);

formatted.lastCrawl = '<!-- date replaced -->';
Expand Down
19 changes: 17 additions & 2 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ const defaultConfig = {
],
indexRules: [
{
objectID: 'promote-exact',
description: 'promote exact matches',
objectID: 'promote-exact-old',
description: 'promote exact matches (old, delete me in a next PR)',
condition: {
pattern: '{facet:_searchInternal.concatenatedName}',
anchoring: 'is',
Expand All @@ -73,6 +73,21 @@ const defaultConfig = {
},
},
},
// not yet enabled, but to be done in a replica after this is merged and
// in production
// {
// objectID: 'promote-exact',
// description: 'promote exact matches',
// condition: {
// pattern: '{facet:_searchInternal.alternativeNames}',
// anchoring: 'is',
// },
// consequence: {
// params: {
// automaticOptionalFacetFilters: ['_searchInternal.alternativeNames'],
// },
// },
// },
],
};

Expand Down
2 changes: 2 additions & 0 deletions src/formatPkg.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default function formatPkg(pkg) {
const dependencies = cleaned.dependencies || {};
const devDependencies = cleaned.devDependencies || {};
const concatenatedName = cleaned.name.replace(/[-/@_.]+/g, '');
const splitName = cleaned.name.replace(/[-/@_.]+/g, ' ');

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

Expand Down Expand Up @@ -93,6 +94,7 @@ export default function formatPkg(pkg) {
lastCrawl: new Date().toISOString(),
_searchInternal: {
concatenatedName,
alternativeNames: [concatenatedName, splitName, name],
},
};

Expand Down

0 comments on commit 9a24fcc

Please sign in to comment.