Using temporal operator search-attribute create

I can create custom search attribute using:

temporal operator search-attribute create -n test --name CampaignName --type Keyword --yes

However they don’t seem to register until after I restart the temporal dev server. What am I doing wrong?

Do you get the same issue using tctl?

tctl adm cl asa -n <name> -t <type>

There is around a 10s delay from when you request adding a customer search attribute to when you can start using it. Any errors in service logs by chance?

temporal operator search-attribute create -n test --name TestCampaignName --type Keyword --yes
You are about to add search attributes [TestCampaignName:Keyword]. Continue? Y/N yes
Search attributes have been added
temporal operator search-attribute create -n test --name TestCampaignDescription --type Keyword --yes
You are about to add search attributes [TestCampaignDescription:Keyword]. Continue? Y/N yes
Search attributes have been added

I wait 30 seconds:

go run cmd/test/main.go campaign create -n bulgary -d bulgary\ campaign
2023/02/28 03:42:38 INFO  No logger configured for temporal client. Created default one.
2023/02/28 03:42:38 unable to check for existing workflow: Namespace test has no mapping defined for search attribute TestCampaignName
Error: Namespace test has no mapping defined for search attribute TestCampaignName

If I run it again:

➜  /com.docker.devenvironments.code git:(main) make setup                                                               
temporal operator search-attribute create -n test --name TestCampaignName --type Keyword --yes
You are about to add search attributes [TestCampaignName:Keyword]. Continue? Y/N yes
Search attributes have been added
temporal operator search-attribute create -n test --name TestCampaignDescription --type Keyword --yes
Search attributes already exist

I wait a bit again:

➜  /com.docker.devenvironments.code git:(main) make setup
temporal operator search-attribute create -n test --name TestCampaignName --type Keyword --yes
Search attributes already exist
temporal operator search-attribute create -n test --name TestCampaignDescription --type Keyword --yes
Search attributes already exist

and now it works

➜  /com.docker.devenvironments.code git:(main) go run cmd/test/main.go campaign create -n bulgary -d bulgary\ campaign
2023/02/28 03:47:14 INFO  No logger configured for temporal client. Created default one.
2023/02/28 03:47:14 Started workflow WorkflowID 757a8b7c-2f27-4c8d-9fdd-63d770b66ac5 RunID 80c4fddc-6fc7-4650-9af6-fcb34a9bf711

It isn’t so much of an issue since I only have to create the search attributes once.

Well I didn’t tctl… I switched to tctl next and then got a deprecation message telling me to use temporal CLI so I did.

The custom search attributes may take up to 1 minute after you add it to be available to use (not 10 seconds).

Just to follow up, using temporal cli, I can’t create search attributes reliably… even if I wait for ten minutes.

using tctl it worked on first trial.

temporal --version
temporal version 0.5.0 (server 1.20.0) (ui 2.10.3))

tctl --version
tctl version 1.18.0

Do you get any errors? Can you share the exact commands you ran and the output?

Also, did you check if there were any error logs from the Server?

What’s your setup? ES or SQL DB?