I am trying to dynamically define search attributes via the Java SDK. After researching this, it seems like this is only possible via the CLI. That being the case, is there a way for tctl commands to be executed from the Java SDK?
You don’t have to use tctl and can use Operator Service, for example:
OperatorServiceStubs operatorService = OperatorServiceStubs.newServiceStubs(
OperatorServiceStubsOptions.newBuilder()
.setChannel(service.getRawChannel())
.validateAndBuildWithDefaults());
// ...
operatorService.blockingStub().addSearchAttributes(AddSearchAttributesRequest.newBuilder()
.putAllSearchAttributes(Collections.singletonMap("MySuperCustom", IndexedValueType.INDEXED_VALUE_TYPE_TEXT))
.build());
Where “service” is your normal WorkflowService.
You can add multiple at a time. Just note it might take (believe up to 10s) for them to be registered with the cluster, can check with
tctl cl gsa
Sorry for the delay. This worked perfectly. Thank you!