Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EDU-3817: Use value_set/unset to update search attributes #3300

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions docs/develop/python/observability.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -218,20 +218,20 @@ These attributes are useful for querying Workflows based on the customer ID or t

You can upsert Search Attributes to add or update Search Attributes from within Workflow code.

To upsert custom Search Attributes, use the [`upsert_search_attributes()`](https://python.temporal.io/temporalio.workflow.html#upsert_search_attributes) method to pass instances of `SearchAttributePair()` containing each of your keys and starting values to a parameter to a `TypedSearchAttributes()` object:
To upsert custom Search Attributes, use the [`upsert_search_attributes()`](https://python.temporal.io/temporalio.workflow.html#upsert_search_attributes) method to pass a list of `SearchAttributeUpdate()`. These can be created via value_set calls on search attribute keys:
fairlydurable marked this conversation as resolved.
Show resolved Hide resolved

```python
workflow.upsert_search_attributes(TypedSearchAttributes([
SearchAttributePair(customer_id_key, "customer_2")
]))
workflow.upsert_search_attributes([
customer_id_key.value_set("customer_2")
])
```

### Remove a Search Attribute from a Workflow {#remove-search-attribute}

To remove a Search Attribute that was previously set, set it to an empty array: `[]`.
To remove a Search Attributes that was previously set, use a value_unset call on the search attribute key.
fairlydurable marked this conversation as resolved.
Show resolved Hide resolved

```python
workflow.upsert_search_attributes(TypedSearchAttributes([
SearchAttributePair(customer_id_key, [])
]))
workflow.upsert_search_attributes([
customer_id_key.value_unset()
])
```