Skip to content

Commit

Permalink
feat(query rules): add filtering on attr:value (#221)
Browse files Browse the repository at this point in the history
Added it on `author:{owner.name}`, `owner:{owner.name}` and `keyword:{keywords}`. Do you have more suggestions @vvo?
  • Loading branch information
Haroenv authored Oct 8, 2018
1 parent 97a617a commit ebcbf56
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
63 changes: 63 additions & 0 deletions src/__tests__/__snapshots__/config.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,69 @@ Object {
"description": "promote exact matches",
"objectID": "promote-exact",
},
Object {
"condition": Object {
"anchoring": "contains",
"pattern": "author\\\\: {facet:owner.name}",
},
"consequence": Object {
"params": Object {
"automaticFacetFilters": Array [
"owner.name",
],
"query": Object {
"remove": Array [
"author\\\\:",
"{facet:owner.name}",
],
},
},
},
"description": "filter on author: {owner.name}",
"objectID": "author:owner",
},
Object {
"condition": Object {
"anchoring": "contains",
"pattern": "owner\\\\: {facet:owner.name}",
},
"consequence": Object {
"params": Object {
"automaticFacetFilters": Array [
"owner.name",
],
"query": Object {
"remove": Array [
"owner\\\\:",
"{facet:owner.name}",
],
},
},
},
"description": "filter on owner: {owner.name}",
"objectID": "owner:owner",
},
Object {
"condition": Object {
"anchoring": "contains",
"pattern": "keyword\\\\: {facet:keywords}",
},
"consequence": Object {
"params": Object {
"automaticFacetFilters": Array [
"keywords",
],
"query": Object {
"remove": Array [
"keyword\\\\:",
"{facet:keywords}",
],
},
},
},
"description": "filter on keyword: {keywords}",
"objectID": "keyword:keyword",
},
],
"indexSettings": Object {
"attributesForFaceting": Array [
Expand Down
48 changes: 48 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,54 @@ const defaultConfig = {
},
},
},
{
condition: {
pattern: 'author\\: {facet:owner.name}',
anchoring: 'contains',
},
consequence: {
params: {
automaticFacetFilters: ['owner.name'],
query: {
remove: ['author\\:', '{facet:owner.name}'],
},
},
},
description: 'filter on author: {owner.name}',
objectID: 'author:owner',
},
{
condition: {
pattern: 'owner\\: {facet:owner.name}',
anchoring: 'contains',
},
consequence: {
params: {
automaticFacetFilters: ['owner.name'],
query: {
remove: ['owner\\:', '{facet:owner.name}'],
},
},
},
description: 'filter on owner: {owner.name}',
objectID: 'owner:owner',
},
{
condition: {
pattern: 'keyword\\: {facet:keywords}',
anchoring: 'contains',
},
consequence: {
params: {
automaticFacetFilters: ['keywords'],
query: {
remove: ['keyword\\:', '{facet:keywords}'],
},
},
},
description: 'filter on keyword: {keywords}',
objectID: 'keyword:keyword',
},
],
};

Expand Down

2 comments on commit ebcbf56

@vvo
Copy link
Contributor

@vvo vvo commented on ebcbf56 Oct 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more suggestions: none at the moment, good feature

@Haroenv
Copy link
Collaborator Author

@Haroenv Haroenv commented on ebcbf56 Oct 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the ping again, that was months ago and you already reviewed the PR then :)

Please sign in to comment.