Skip to content

Logical query with pattern without key #736

Closed as not planned
Closed as not planned

Description

@ashtraysoap

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

Is there a way to perform a logical query containing a simple pattern without key speciication (e.g. { $and: [{ key1: "abc"}, "xyz"]}).

Trying the pattern from the example yields no matches even though there should be some.

Is there an altenative way to achieve this query in Fuse, or is it not supported?

Desired solution

Ideally, the pattern exemplified in { $and: [{ key1: "abc"}, "xyz"]} would work so that it would return results containing a match for "abc" in the key key1 and simultaneously a match for in xyz in any of the indexed fields (similarly to fuse.search("xyz")).

Alternatives considered

I've found no way to achieve given query in Fuse.The query pattern seems relatively orthodox (at least in my usecase), it would be helpful, if it was supported by the library.

Additional context

No response

Activity

  1. krisk commented on Oct 25, 2023

    @krisk
    Owner

    Could you give an example list and search query to show the above? Ultimately the way logical operators work is by operating on a single list item, so the item itself would have to be match both patterns in the AND query. Perhaps I am not fully understanding the feature ask, so an example would help. Thanks! :)

  2. github-actions commented on Feb 23, 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

  3. ashtraysoap commented on Jun 19, 2024

    @ashtraysoap
    Author

    Thanks for the reply, and my apologies for my delay.

    Given the input data:
    [ { name: "Albert", city: "London", }, { name: "Albert", city: "Paris", }, { name: "Arnold", city: "Paris" }, ]

    I want to achieve the following filter: match all items with Albert in name and Paris in any other field.

    I would expect the query { $and: [{ name: "Albert"}, "Paris"]} to achieve this, however it does not work.

    Thanks!

  4. ashtraysoap commented on Sep 10, 2024

    @ashtraysoap
    Author

    @krisk could you please provide an update whether this functionality is available?

  5. added a commit that references this issue on Apr 3, 2026
    8695556
  6. krisk commented on Apr 3, 2026

    @krisk
    Owner

    Fixed in 8695556. You can now use plain strings in $and/$or arrays to search across all indexed keys:

    fuse.search({
      $and: [{ title: "old" }, "Scalzi"]
    })

    The keyless string "Scalzi" searches all keys, while { title: "old" } targets only the title field.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions