Search does not seem to work for tags with emoji

I have tags that contain emojis, e.g. new-york-city-🇺🇸.
When using the search and advanced search, I don’t get the topics.

Here is an example:
Query:
https://urbantech-forum.cornelltech.io/search?expanded=true&q=tags%3Anew-york-city-🇺🇸subway

And here is a topic that should be returned:

1 Like

Not sure if this is resolvable, what is your take @neil?

AFAIK it’s only because the regex we have here:

is not allowing emojis. If this was matching on emoji, it would work after.

We might want to consider using something like: GitHub - ticky/ruby-emoji-regex: 💎 A pair of Ruby regular expressions for matching Unicode Emoji symbols. to have a good emoji regex.

what do you think @sam ?

1 Like

Oh my, this feels like one big monster to support for a major edge case, do we already have a validating regex on the Tag class?

1 Like

I don’t think we do, might be wrong though @neil probably knows better
AFAIK we just have this clean_tag function:

Which is kinda copied in client side here:

Also this would probably be useful at other places as we for example generate this client side: discourse/emoji.js.es6 at master · discourse/discourse · GitHub

2 Likes

I doubt that we have any tests for emoji tag names. Maybe we can look into supporting this in 2.5?

4 Likes

I see that the search returns only one topic when using only the tag (without the subway keyword) in the search (it’s not the topic posted in the OP):

https://urbantech-forum.cornelltech.io/search?expanded=true&q=tags%3Anew-york-city-🇺🇸

It also works with other keywords (but only for that topic returned previously):

https://urbantech-forum.cornelltech.io/search?expanded=true&q=tags%3Anew-york-city-🇺🇸%20personal

If I don’t use tags it returns correctly:

https://urbantech-forum.cornelltech.io/search?expanded=true&q=new-york-city-🇺🇸

The topic returned previously, with the tag, is the 1st returned using a keyword with the tag name, but the post is another (but it might just be because of (maybe) a metadata or something like this in the post that is caught by the search, and not the tag itself, but I can’t say for sure).