Get all assets that have a specific Atlan tag¶
This example finds all assets that are assigned a specific Atlan tag — irrespective of whether they were directly assigned the tag or it was propagated.
Get all assets with a specific tag | |
---|---|
1 2 3 4 5 6 7 |
|
- 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. - The
CompoundQuery.tagged()
helper method allows us to limit to assets that match at least one of potentially multiple values (since there could be many tags on an asset). The SDK will translate the provided Atlan tag into the necessary internal representation required for the search — you can just provide the human-readable names of the Atlan tags. - 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 specific tag | |
---|---|
1 2 3 4 5 6 7 8 9 10 |
|
- 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. - The
CompoundQuery.tagged()
helper method allows us to limit to assets that match at least one of potentially multiple values (since there could be many tags on an asset). The SDK will translate the provided Atlan tag into the necessary internal representation required for the search — you can just provide the human-readable names of the Atlan tags. - 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 Atlan tags, you first need to have the Atlan-internal hashed-string representation of the tags. 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 20 21 22 23 24 25 26 27 28 29 30 |
|
- Run a search to find the assets.
- To match both assets that are directly assigned the Atlan tag and those that were propagated the Atlan tag, use a
bool
query for multiple conditions. - Define the minimum number of conditions that need to match on an asset to be included in the results. In this example, you want either a direct or propagated Atlan tag, so should match at least one of the conditions provided.
- Use
__traitNames
to match directly-classified assets. - Use the Atlan-internal hashed-string representation of the Atlan tag.
- Use
__propagatedTraitNames
to match assets that have been propagated this Atlan tag. - Once again, use the Atlan-internal hashed-string representation of the Atlan tag.