Custom Searchattributes

  1. is it possible to add/change search attributes on a workflow, after it has already started ?

  2. We ( java-sdk ) need to add search attributes of the type AAA=xxx on our workflows.
    I don’t see any examples. ( Im not able to understand what HelloSearchAttributes.java is doing )
    We would like to get examples of both writing and searching

  3. Once we locate the workflow ( workflowId/runId ), how do we retrieve the value of AAA ?

  1. Yes. Use Workflow.UpsertSearchAttributes API.

  2. It starts a workflow passing a few custom search attribute values. Note that each attribute has to be registered with the service before SDK can use it.

  3. They are available in the response to the DescribeWorkflowExecution API. But if you are doing this, I’m not sure why you are using search attributes instead of a workflow query. The idea for search attributes is that they can be used to list workflows by their values.

( Thank you very much Maxim )

Oh. So each search attribute tag ( AAA ) has to be added through tctl ?
So what can be passed to workflow programmatically ? ( value xxx for the tag AAA ? )

–sony

Oh. So each search attribute tag ( AAA ) has to be added through tctl ?

Yes, you are correct. Custom search attributes correspond to fields in the Elasticsearch schema. So when you register one through tctl the ES schema is updated.

So what can be passed to workflow programmatically ? ( value xxx for the tag AAA ? )

Yes, you pass key-value pair with “AAA” being the key.

We do not have an Elastic Search plugin ( Although we have plans to install that in the future )
Are you saying we cannot attach arbitrary TAG=VALUE s to workflows without installing elastic search ?

Are you saying we cannot attach arbitrary TAG=VALUE s to workflows without installing elastic search ?

What is your use case? I think you are trying to achieve something that custom search attributes were not designed for.

We have a workflow that processes requests on specific business objects.

Multiple workflows types make multiple changes .
Our design is to attach business object name to workflow as OUR_BUSINESS_OBJECT=objectname as a search attribute… we will also add another search attribute VERSION=versionnumber

( my questions were related to this part )Then from another part of our software, we should be able to query for specific business objects…Our current design is to Temporal search for the specific business object name …once we locate the workflow(workflowid/runid), we will get some data using our queryMethod() on the workflow

Have you considered using the “business name” as workflow ID to avoid that lookup step?

Are you saying we cannot attach arbitrary TAG=VALUE s to workflows without installing elastic search ?

Yes, custom search attributes require Elasticsearch integration.

Sorry. I got confused on this again:

Yes, custom search attributes require Elasticsearch integration.

I ran the default docker-compose.yml ( Cassandra with no ES ). Using this I was successfully able to run io.temporal.samples.hello.HelloSearchAttributes, which uses workflowoptions.setSearchAttributes() and searchAttributes.getIndexedFieldsOrThrow(“CustomStringField”)

So when exactly do you need ElasticSearch ?

So when exactly do you need ElasticSearch ?

To perform a search using the “CustomStringField”. You can add attributes to a workflow without ES running, but these attributes cannot be used to filter workflows while listing them.

Are you saying :
String query = …
ListWorkflowExecutionsRequest req = ListWorkflowExecutionsRequest.newbuilder().setQuery(query).build() ;
WorkflowService.listWorkflowExecutions(req)

…will fail if the Temporal instance is not backed by an Elastic Search ?
…although workflowoptions.setSearchAttributes() will succeed

?

We are a fairly large organization with a different team running the Temporal instances.
( Our team is not given access to tctl )
is there a way for us to check if our temporal instance is backed up by Elastic Search ? ( We have access to teh web ui )

I figured this out

GetSearchAttributesRequest gsa = GetSearchAttributesRequest.newBuilder().build();
      GetSearchAttributesResponse gsares = service.blockingStub().getSearchAttributes(gsa);
      // System.out.println( gsares.toString());

On the Web-ui side you could click on the “Advanced” button on the top-right side and try to run a query, for example: “ExecutionStatus=2” (to query completed workflows). If it returns results you should have ES capabilities turned on.

Ah. Thanks. very useful.

By teh way… what is the Visibility Archival under Settings

VISIBILITY ARCHIVAL

Disabled

believe the docs might be a little bit outdated as in visibility archival is available (still considered experimental) and works if history archival is enabled.