Skip to content

Allow for options in $regex filter #204

Description

@re-kfa

Hi,
currently it is not possible to apply options to a regexp when using the fetchByFilter method.

The reason is that the value is always treated as string and not as a regex.

So this is not working:

await fsxaApi.fetchByFilter({
  filters: [
    {
      field: 'formData.st_searchterms.value',
      operator: '$regex',
      value: "/Suchbegriff(,|$){1}/i",
    },
  ],
});

The query builder renders this url:
&filter={"formData.st_searchterms.value":{"$regex":"/Suchbegriff(,|$){1}/i"}}

But for the Mongodb to correctly interpret the regexp the quotes need to be omitted:
&filter={"formData.st_searchterms.value":{"$regex":/Suchbegriff(,|$){1}/i}}

Alternatively it is possible to work with this syntax according to the MongoDB-Documentation:
&filter={"formData.st_searchterms.value":{"$regex":"OnlineService(,|$){1}", "$options": "i"}}

So possibly allowing an option property in the filter object would also help here.

Thanks!

Activity

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

    documentationImprovements or additions to documentationgood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions