krisk / Fuse

Lightweight fuzzy-search, in JavaScript
https://fusejs.io/
Apache License 2.0
17.76k stars 753 forks source link

Extended search not working with AND at all #745

Closed marceloverdijk closed 3 months ago

marceloverdijk commented 8 months ago

Is there an existing issue for this?

Description of the bug

This is similar as https://github.com/krisk/Fuse/issues/633 but which was closed.

With example from https://www.fusejs.io/demo.html and extended search enabled, searching ^old scal gives no results although I would have expected that Old Man's War from John Scalzi would have been returned.

Changing to ^old | scal does give the result.

Also just old scal does not give any results, but with old | scal it does.

When disabling useExtendedSearch = false then old scal gives the result.

It seems when useExtendedSearch = true is set an AND search is not working at all (compared to OR search with | is working).

The Fuse.js version where this bug is happening.

6.6.2

Is this a regression?

Which version did this behavior use to work in?

None

Steps To Reproduce

See description.

Expected behavior

AND to work with extend search enabled.

Screenshots

No response

Additional context

No response

marceloverdijk commented 8 months ago

Note that this works as well:

fuse.search({
  $and: [
    { 'title': '^old' }, 
    { 'author.lastName: 'scal' }, 
  ]
})

but fuse.search('^old scal') does not.

The spaces seem not to be parsed correctly.

Note the extended docs state:

White space acts as an AND operator, while a single pipe (|) character acts as an OR operator.

github-actions[bot] commented 4 months ago

This issue is stale because it has been open 120 days with no activity. Remove stale label or comment or this will be closed in 30 days