Skip to content

Support escaping the OR operator (|) when extended search is enabled #765

Closed as not planned

Description

@smithki

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

Extended search is a critical piece of Fuse.js, but it has some limitations when searching fields that contain pipe characters (|). If we could escape the OR operator, this could be worked around for a case like this:

const myData = [
  { example: "for | some | reason | there's | pipes | in | this | string" },
];

const fuse = new Fuse(myData, {
  keys: ["example"],
  useExtendedSearch: true,
});

fuse.search({
  example: `some \\| reason`, // fuzzy match includes pipe character
});

fuse.search({
  example: `^"for \\| some" "this \\| string"$`, // match prefix AND suffix including pipe characters
});

fuse.search({
  example: `^"for \\| some" | "this \\| string"$`, // match prefix OR suffix including pipe characters
});

Desired solution

Easy: support escaping pipe operators present in extended search queries using backslashes (i.e. \\|)

Alternatives considered

I don't see an alternative to achieve this with Fuse at the moment. For my use-case, this complicates things when queries need to mix exact matches for some fields with fuzzy matches for others.

Additional context

No response

Activity

  1. github-actions commented on Aug 9, 2024

    @github-actions

    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

  2. added a commit that references this issue on Apr 2, 2026
    d33b735
  3. krisk commented on Apr 2, 2026

    @krisk
    Owner

    Fixed in d33b735. You can now escape the pipe character with \\| in extended search queries. Unescaped | continues to work as the OR operator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions