Skip to content

Commit

Permalink
feat(relevance): put name, description and eywords on same level (#188)
Browse files Browse the repository at this point in the history
This will give significantly more relevant results (you can try it out with the index `npm-search-relevance-test` I created to test out these settings.

I had to remove the settings to disable exact and prefix from those attributes, because it otherwise clashes with errors like

```
invalid setting for disablePrefixOnAttributes, you should requests all attributes with same priority: attr1, attr2,  does not exists
```

cc @redox, since you did the original ranking decisions here 😄
  • Loading branch information
Haroenv committed Apr 28, 2018
1 parent d477bf9 commit ee62193
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 24 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ We're restricting the search to use a subset of the attributes only:

##### Prefix Search

Algolia provides default prefix search capabilities (matching words with only the beginning). This is disabled for the `keywords`, `owner.name` and `owners.name` attributes.
Algolia provides default prefix search capabilities (matching words with only the beginning). This is disabled for the `owner.name` and `owners.name` attributes.

##### Typo-tolerance

Algolia provides default typo-tolerance. Typo-tolerance is disabled for the `keywords` attribute.
Algolia provides default typo-tolerance.

##### Exact Boosting

Expand Down
11 changes: 1 addition & 10 deletions src/__tests__/__snapshots__/config.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,13 @@ Object {
"desc(downloadsLast30Days)",
],
"disableExactOnAttributes": Array [
"description",
"keywords",
"owner.name",
"owners.name",
],
"disablePrefixOnAttributes": Array [
"keywords",
"owner.name",
"owners.name",
],
"disableTypoToleranceOnAttributes": Array [
"keywords",
],
"exactOnSingleWordQuery": "attribute",
"optionalWords": Array [
"js",
Expand All @@ -71,10 +65,7 @@ Object {
"replaceSynonymsInHighlight": false,
"searchableAttributes": Array [
"unordered(_searchInternal.popularName)",
"unordered(name)",
"unordered(_searchInternal.concatenatedName)",
"unordered(description)",
"unordered(keywords)",
"unordered(name), unordered(_searchInternal.concatenatedName), unordered(description), unordered(keywords)",
"owner.name",
"owners.name",
],
Expand Down
15 changes: 3 additions & 12 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ const defaultConfig = {
indexSettings: {
searchableAttributes: [
'unordered(_searchInternal.popularName)',
'unordered(name)',
'unordered(_searchInternal.concatenatedName)',
'unordered(description)',
'unordered(keywords)',
'unordered(name), unordered(_searchInternal.concatenatedName), unordered(description), unordered(keywords)',
'owner.name',
'owners.name',
],
Expand All @@ -36,14 +33,8 @@ const defaultConfig = {
'desc(dependents)',
'desc(downloadsLast30Days)',
],
disablePrefixOnAttributes: ['keywords', 'owner.name', 'owners.name'],
disableExactOnAttributes: [
'description',
'keywords',
'owner.name',
'owners.name',
],
disableTypoToleranceOnAttributes: ['keywords'],
disablePrefixOnAttributes: ['owner.name', 'owners.name'],
disableExactOnAttributes: ['owner.name', 'owners.name'],
exactOnSingleWordQuery: 'attribute',
ranking: [
'filters',
Expand Down

0 comments on commit ee62193

Please sign in to comment.