Get all assets that have custom metadata¶
With any value¶
This example finds all assets with a particular custom metadata attribute populated — irrespective of the specific value of the attribute.
Get all assets with a custom metadata attribute populated | |
---|---|
1 2 3 4 5 6 7 8 |
|
- Start with a client to run the search through. For the default client, you can always use
Atlan.getDefaultClient()
. - To search across all assets, you can use the
assets.select()
convenience method on a client. -
When searching for custom metadata attributes, you can construct a
CustomMetadataField
to start a clause that will match a custom metadata property. Since you are searching for the custom metadata attribute itself, there is no enum for the custom metadata or its property names, so these must be provided as strings. (TheCustomMetadataField
will handle translating these from their human-readable values to the Atlan-internal ID strings needed for the search.)The
hasAnyValue()
predicate allows you to limit to assets that have any value for this custom metadata attribute. -
Since you are searching for custom metadata, you probably want to include the values for custom metadata in each search result. This
getAttributesForSearchResults()
helper method will return all of the custom attributes within theRACI
custom metadata structure. These will be encoded in the specific form required by the search for you.Note the use of
_includesOnResults
Since the
getAttributesForSearchResults()
helper will return a list of strings, you'll need to use the special_includesOnResults()
method to add these for inclusion. -
The search will only run when you call the
stream()
method, which will then lazily-load each page of results into a stream. - This is the pattern for iterating through all results (across pages) covered in the Searching for assets portion of the SDK documentation.
Get all assets with a custom metadata attribute populated | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 |
|
- Start with a client to run the search through. For the default client, you can always use
AtlanClient()
. -
To search across all assets, you can use a
FluentSearch
object.Since you are searching for custom metadata, you probably want to include the values for custom metadata in each search result. This
get_attributes_for_search_results()
helper method will return all of the custom attributes within theRACI
custom metadata structure. These will be encoded in the specific form required by the search for you.Note the use of
_includes_on_results
Since the
get_attributes_for_search_results()
helper will return a list of strings, you'll need to use the special_includes_on_results
parameter to add these for inclusion. -
When searching for custom metadata attributes, you can construct a
CustomMetadataField
to start a clause that will match a custom metadata property. Since you are searching for the custom metadata attribute itself, there is no enum for the custom metadata or its property names, so these must be provided as strings. (TheCustomMetadataField
will handle translating these from their human-readable values to the Atlan-internal ID strings needed for the search.)The
has_any_value()
predicate allows you to limit to assets that have any value for this custom metadata attribute. -
You can then translate the fluent search into an index search request.
- This is the pattern for iterating through all results (across pages) covered in the Searching for assets portion of the SDK documentation.
Requires multiple API operations
Before you can search for custom metadata, you first need to have the Atlan-internal hashed-string representation of the custom metadata property. You will likely need to first retrieve the hashed-string representation.
POST /api/meta/search/indexsearch | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
- Run a search to find the assets.
- For a search with only a single condition, we can directly provide the condition.
- You can use the
exists
criteria to match any assets that have some value (no matter what that value is) for a given field. - Use the Atlan-internal hashed-string representation of the custom metadata field name.
- Include the Atlan-internal hashed-string representation of the custom metadata field name in the attributes list, so you can see the value of the custom metadata on each result. In this attributes list it needs to be written as
<CustomMetadata>.<Attribute>
, using the hashed-string representation for both pieces.
With a specific value¶
This example finds all assets with a particular custom metadata attribute populated — with a specific value for the attribute.
Get all assets with a specific custom metadata attribute value | |
---|---|
1 2 3 4 5 6 7 8 |
|
- Start with a client to run the search through. For the default client, you can always use
Atlan.getDefaultClient()
. - To search across all assets, you can use the
assets.select()
convenience method on a client. -
When searching for custom metadata attributes, you can construct a
CustomMetadataField
to start a clause that will match a custom metadata property. Since you are searching for the custom metadata attribute itself, there is no enum for the custom metadata or its property names, so these must be provided as strings. (TheCustomMetadataField
will handle translating these from their human-readable values to the Atlan-internal ID strings needed for the search.)The
eq()
predicate allows you to limit to assets that have only the exact value provided for this custom metadata attribute. -
Since you are searching for custom metadata, you probably want to include the values for custom metadata in each search result. This
getAttributesForSearchResults()
helper method will return all of the custom attributes within theRACI
custom metadata structure. These will be encoded in the specific form required by the search for you.Note the use of
_includesOnResults
Since the
getAttributesForSearchResults()
helper will return a list of strings, you'll need to use the special_includesOnResults()
method to add these for inclusion. -
The search will only run when you call the
stream()
method, which will then lazily-load each page of results into a stream. - This is the pattern for iterating through all results (across pages) covered in the Searching for assets portion of the SDK documentation.
Get all assets with a custom metadata attribute populated | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 |
|
- Start with a client to run the search through. For the default client, you can always use
AtlanClient()
. -
To search across all assets, you can use a
FluentSearch
object.Since you are searching for custom metadata, you probably want to include the values for custom metadata in each search result. This
get_attributes_for_search_results()
helper method will return all of the custom attributes within theRACI
custom metadata structure. These will be encoded in the specific form required by the search for you.Note the use of
_includes_on_results
Since the
get_attributes_for_search_results()
helper will return a list of strings, you'll need to use the special_includes_on_results
parameter to add these for inclusion. -
When searching for custom metadata attributes, you can construct a
CustomMetadataField
to start a clause that will match a custom metadata property. Since you are searching for the custom metadata attribute itself, there is no enum for the custom metadata or its property names, so these must be provided as strings. (TheCustomMetadataField
will handle translating these from their human-readable values to the Atlan-internal ID strings needed for the search.)The
eq()
predicate allows you to limit to assets that have only the exact value provided for this custom metadata attribute. -
You can then translate the fluent search into an index search request.
- This is the pattern for iterating through all results (across pages) covered in the Searching for assets portion of the SDK documentation.
Requires multiple API operations
Before you can search for custom metadata, you first need to have the Atlan-internal hashed-string representation of the custom metadata property. You will likely need to first retrieve the hashed-string representation.
POST /api/meta/search/indexsearch | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
- Run a search to find the assets.
- For a search with only a single condition, we can directly provide the condition.
- You can use the
term
query to exactly match a value on assets, for a given field. - Use the Atlan-internal hashed-string representation of the custom metadata field name.
- Provide the exact value you want to match in that custom metadata property.
- Include the Atlan-internal hashed-string representation of the custom metadata field name in the attributes list, so you can see the value of the custom metadata on each result. In this attributes list it needs to be written as
<CustomMetadata>.<Attribute>
, using the hashed-string representation for both pieces.