List filter wildcard query not returning expected results

Hi,

we are trying to improve our queries to search for workflows by certain custom search attributes by adding also a wildcard search. We followed the documentation about the List Filter and our expectation was that we can use the queries like following (from the docs - advanced visibility is enabled):

// Create a "ProductId" custom Search Attribute of type String
tctl admin cluster add-search-attributes --name ProductId --type String
// Match values that start with "book"
ProductId LIKE "book%"
// Match values that contain "favorite"
ProductId LIKE "%favorite%"

Now we have a custom search attribute StatusText that is of type Text . The values can be for example something like waiting for user , waiting for payment , payment received or payment declined .

However, the queries are not returning the expected result (using tctl workflow list -q )

StatusText LIKE "waiting for user" // result: all workflows with StatusText "waiting for user" = what we expectation 

StatusText LIKE "waiting%" // result: nothing - expectation: values starting with "waiting"
StatusText LIKE "waiting" // result: returns all workflows containing "waiting" - expectation: no results (exact match)
StatusText LIKE "waiting payment" // result: returns all workflows containing "waiting" and "payment" ("waiting for user", "waiting for payment", "payment received", "payment declined") - expectation: no results
StatusText LIKE "waiting%payment" // result: nothing - expectation: values containing "waiting" and "payment" -> "waiting for payment"
StatusText LIKE "waiting rubbish" // result: returns all workflows containing "waiting" - expectation: no results
StatusText LIKE "%payment%" // result: nothing - expectation: values containing "payment" ("waiting for payment", "payment received", "payment declined")

It doesn’t matter if we’re using % as a wildcard or * , they do not work as expected - and the LIKE operator matches all values that contain any of the given values. So we wonder what causes this behaviour and why it doesn’t work as described in the documentation. What are we doing wrong? Or are the results described above the expected behaviour?

(The behaviour is the same for running Temporal locally with the docker containers as well as in Temporal Cloud)

All the best,
Chris

Hello @chkl

you are not doing anything wrong. Right now Temporal does not support wildcards in queries, the team is working to fix the documentation https://github.com/temporalio/documentation/pull/1919 Apologies for the confusion.

Now we have a custom search attribute StatusText that is of type Text . The values can be for example something like waiting for user , waiting for payment , payment received or payment declined .

If you want to search for a specific token/word, the recommendation is what you are doing here, create a search attribute type Textwith the value of the tokens you want to search separated by spaces, punctuation… and use = instead like.

Tested locally with TEMPORAL_VERSION=1.20.0

StatusText LIKE “waiting for user” // result: all workflows with StatusText “waiting for user” = what we expectation

will return any workflow containing any of the words (waiting, for, user), same with StatusText = "waiting for user"

StatusText LIKE “waiting%payment” // result: nothing - expectation: values containing “waiting” and “payment” → “waiting for payment”

‘%’ is removed from the query, https://github.com/temporalio/temporal/blob/c099c796325c756878264e38fda2ec9f37c59bc8/common/persistence/visibility/store/query/converter.go#L463 , this will end up being StatusText LIKE "waitingpayment"

Hi @antonio.perez ,

thank you very much for the clarification! At least now we have a better understanding of what to expect from the queries.

Are there any plans for the future to support wildcards or is this currently not on the agenda? Just so that we know if it might change in the future. In the meantime we will need to adjust our requirements to at least support partial string match.

hello @chkl ,

Are there any plans for the future to support wildcards or is this currently not on the agenda?

I am not sure right now, let me ask

Hello @chkl

I am afraid it is not in the roadmap right now, feel free to open a feature request Issues · temporalio/temporal · GitHub