Attribute values starting with dash (-) don't work as tagFilters

I understand that hyphens are special in Algolia and I’ve never had a problem with it. My Firebase objectIDs all start with a dash and that’s never been a problem. A lot of the elements in my _tags attributes have a dash and that works fine too.

But now I’ve tried to add some elements starting with a dash to the _tags attribute and it’s not working as expected. Unlike the items with a dash somewhere in the middle, those starting with a dash don’t work as tagFilters.

Am I doing something wrong? Is there a workaround? These are Firebase IDs…

Hey @ken2

As per usage notes for tagFilters a - is used for negation:

  • Negation is supported by prefixing the tag value with a minus sign ( - ), sometimes called a dash. For example, ["tag1", "-tag2"] translates as tag1 AND NOT tag2 .

You might try escaping the hyphen, however I am not 100% certains this will work e.g.

["tag1", "\-tag2"]

Also found this on Stackoverflow: algolia - How to filter/facet for records that lead with a hyphen - Stack Overflow

Thanks, @the . I hadn’t seen the usage notes. The hyphen prefixed IDs were appearing and behaving nicely in the dashboard (DASH board :roll_eyes:). I didn’t think it was bug, just missing from the doc.

Anyway, the feature I am working on is not yet in production so I change way these IDs are created by prefixing the Firebase push ID with an alphanumeric character.

It seems that the first part of these Firebase IDs is based on a timestamp. For now, we’re only up to “-M” so eventually, a few years from now, Firebase IDs will start with zero not hyphen, bringing some new problems…