Skip to content

Feature/fuzzy match#321

Merged
gr0uch merged 4 commits intofortunejs:masterfrom
cecemel:feature/fuzzy-match
Jun 23, 2020
Merged

Feature/fuzzy match#321
gr0uch merged 4 commits intofortunejs:masterfrom
cecemel:feature/fuzzy-match

Conversation

@cecemel
Copy link
Copy Markdown
Contributor

@cecemel cecemel commented Jun 18, 2020

See also: fortunejs/fortune-json-api#73

Works both directly on the attributes of a record and attributes
of (nested) relation of the record.

Due to filtering on these relations, the change was a bit more
complex.

The adapter instance needs to be passed down the whole chain of
matching, since extra queries need to occur to walk the path of
relations.

Extra Notes

leaf must refer to attribute

It somewhat assumes the last leaf in the path refers to an attribute
of a record. If it ends in a relation, this won't provide the results you
want as a user.

This will work:

store.find('user', undefined, {
  fuzzyMatch: {
   name: 'john D',
   'address:building:rooms:roomName': 'Room X'
   }
  }
)

This not:

store.find('user', undefined, {
  fuzzyMatch: {
   name: 'john D',
   'address:building': 'Building Y'
   }
  }
)

interface in the options object

The options object

  fuzzyMatch: {
   'name': 'john D',
   'address:building:name': 'Building Y'
   }
  }

might be debatable. I understand

  fuzzyMatch: {
    name: 'john D',
    address: {
      building {
        name: 'Building Y'
      }
     }
  }

is more uniform. But adds some complexity implementation wise. Let me know what you think.

cecemel added 4 commits June 18, 2020 15:26
Works both directly on the attributes of a record and attributes
of (nested) relation of the record.

Due to filtering on these relations, the change was a bit more
complex.

The adapter instance needs to be passed down the whole chain of
matching, since extra queries need to occur to walk the path of
relations.

Extra note
----------

It somewhat assumes the last leaf in the path refers to an attribute
of a record. If it ends in a relation, this won't provide the results you
want as a user.

This will work:
```
store.find('user', undefined, {
  fuzzyMatch: {
   'name': 'john D'
   'address:building:rooms:roomName': 'Room X'
   }
  }
)
```

This not:
```
store.find('user', undefined, {
  fuzzyMatch: {
   'name': 'john D'
   'address:building': 'Building Y'
   }
  }
)
```
Copy link
Copy Markdown
Member

@gr0uch gr0uch left a comment

Choose a reason for hiding this comment

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

I think a proper fuzzy match would use a string distance metric, but this will do lol.

@gr0uch gr0uch merged commit b105b75 into fortunejs:master Jun 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants