Reputation: 161
I am trying to put filter in the GCP pubsub subscription. My requirement is to add number of codes in the filter. I am using terraform for that.
Here is something that I want to create :
filter = "attributes.code=(\"5426\",\"5427\",\"5428\",\"5429\",\"5430\")"
I checked the above will not work but the google docs have references to syntax something like:
filter = "attributes.code=\"5426\" OR attributes.code=\"5427\""
This one works, but there is a limit on the filter which is 256 bytes if I add all my codes like this then it is not going to work as it throws character limit error.
Is it possible to use RegEx in filter?
I can't do hit and trial as the code is in production so checking with the experts.
Upvotes: 2
Views: 4413
Reputation: 21
You can also try as below. It works for me good. It was less than 256 bytes in my case.
filter = <<EOT
attributes.code=\"5426\" OR attributes.code=\"5427\"
EOT
I used the same for mine like below and it worked well.
filter = <<EOT
attributes.IS_LATEST = "true" AND attributes.ITEM_LIFECYCLE_PHASE != "Preliminary" AND ( attributes.OBJECT_TYPE = "Part" OR attributes.ITEM_TYPE= "Product Specification" ) AND attributes.REVISION_RELEASE_DATE != "0"
EOT
Hope it helps.
Thanks
MacOS.
Upvotes: 1
Reputation: 999
There's currently no support for regexes in Pub/Sub filters. You can follow updates on these filtering features on their public issue trackers:
In the meantime, could you potentially restructure your code formats to make use of the hasPrefix()
function? If you know in advance that you want to handle certain codes together in the same subscription, you could add common prefixes for them that you can later capture using hasPrefix()
.
Upvotes: 2