Skip to content

Commit

Permalink
feat(relevance): add another query rule on name
Browse files Browse the repository at this point in the history
We earlier added a query rule on concatenated name to promote if that matched, but for a query like `react-native`, you still want that first.
  • Loading branch information
Haroenv committed Apr 30, 2018
1 parent bef4c8f commit 34c6df4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/__tests__/__snapshots__/config.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,28 @@ Object {
},
},
"description": "promote exact matches",
"objectID": "promote-exact-concatenated",
},
Object {
"condition": Object {
"anchoring": "is",
"pattern": "{facet:name}",
},
"consequence": Object {
"params": Object {
"automaticOptionalFacetFilters": Array [
"_searchInternal.concatenatedName",
],
},
},
"description": "promote exact matches",
"objectID": "promote-exact",
},
],
"indexSettings": Object {
"attributesForFaceting": Array [
"filterOnly(_searchInternal.concatenatedName)",
"filterOnly(name)",
"searchable(keywords)",
"searchable(computedKeywords)",
"searchable(owner.name)",
Expand Down
16 changes: 15 additions & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const defaultConfig = {
],
attributesForFaceting: [
'filterOnly(_searchInternal.concatenatedName)' /* optionalFacetFilters to boost the name */,
'filterOnly(name)' /* optionalFacetFilters to boost the name */,
'searchable(keywords)',
'searchable(computedKeywords)',
'searchable(owner.name)',
Expand Down Expand Up @@ -61,7 +62,7 @@ const defaultConfig = {
],
indexRules: [
{
objectID: 'promote-exact',
objectID: 'promote-exact-concatenated',
description: 'promote exact matches',
condition: {
pattern: '{facet:_searchInternal.concatenatedName}',
Expand All @@ -73,6 +74,19 @@ const defaultConfig = {
},
},
},
{
objectID: 'promote-exact',
description: 'promote exact matches',
condition: {
pattern: '{facet:name}',
anchoring: 'is',
},
consequence: {
params: {
automaticOptionalFacetFilters: ['_searchInternal.concatenatedName'],
},
},
},
],
};

Expand Down

0 comments on commit 34c6df4

Please sign in to comment.