I would like to add a
where clause to an event with the property
query. I have a long list of values, so instead of adding each value one by one I would like to use glob matching.
Usually the syntax would be
But this does not work (no event matches).
What is the correct way to do this in Amplitude?
Best answer by tracy.guo
In this case, I’d recommend using the “contains” operator instead of the glob match operator. You can add
where ‘query’ contains and then paste a comma separated list into the values section (eg
dog,cat,zebra). From here, the dropdown menu can parse the comma separated list and you should be able to click “Select All” to add all three values to the filter. Now any query value that contains dog or cat or zebra will be returned.
More information on adding a list of values can be found here: https://help.amplitude.com/hc/en-us/articles/360035354552#adding-a-list-of-property-values
The reason I don’t think glob match is a good fit here is that when glob matching, the “?” wildcard matches on a single character and unlike regex, glob match does not typically support the “|” operator. Glob match could potentially work if you glob match for
*zebra*, which should produce the same results as the contains operator, except that glob match is also case sensitive, so only lower cased dog, cat, and zebra values will be returned.
More information on glob match syntax can be found here: https://en.wikipedia.org/wiki/Glob_(programming)#Syntax
Do you think the “contains” operator works for your use case? Let me know your thoughts and if you have any questions!