Search examples
Connection by name and type
You may have noticed that connections in Atlan have qualifiedNames that include a timestamp. As a result, they'ren't trivial to directly construct.
However, you can search for them by name and type to resolve their qualifiedName:
- Java
- Python
- Kotlin
- Raw REST API
List<Connection> connections = Connection.findByName( // (1)
client, // (2)
"production", // (3)
AtlanConnectorType.SNOWFLAKE); // (4)
- Use the
findByNamestatic method on theConnectionclass to search for connections by name and type. If you name your connections uniquely (by type), this should only return a single-item list. - Because this operation will directly search for the asset in Atlan, you must provide it an
AtlanClientthrough which to connect to the tenant. - Provide the name of the connection (this will be exact-matched).
- Provide the type of the connection. You can also (optionally) provide a list of extra attributes you want to retrieve for the connection. Core attributes like
qualifiedNameand its GUID are already included.
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.enums import AtlanConnectorType
client = AtlanClient()
connections = client.asset.find_connections_by_name( # (1)
name="production", # (2)
connector_type=AtlanConnectorType.SNOWFLAKE, # (3)
attributes=[] # (4)
)
- Use the
asset.find_connections_by_namemethod on theAtlanClientclass to search for connections by name and type. If you name your connections uniquely (by type), this should only return a single-item list. - Provide the name of the connection (this will be exact-matched).
- Provide the type of the connection.
- You can also (optionally) provide a list of extra attributes you want to retrieve for the connection. Core attributes like
qualifiedNameand its GUID are already included.
val connections = Connection.findByName( // (1)
client, // (2)
"production", // (3)
AtlanConnectorType.SNOWFLAKE) // (4)
- Use the
findByNamestatic method on theConnectionclass to search for connections by name and type. If you name your connections uniquely (by type), this should only return a single-item list. - Because this operation will directly search for the asset in Atlan, you must provide it an
AtlanClientthrough which to connect to the tenant. - Provide the name of the connection (this will be exact-matched).
- Provide the type of the connection. You can also (optionally) provide a list of extra attributes you want to retrieve for the connection. Core attributes like
qualifiedNameand its GUID are already included.
{
"dsl": { // (1)
"query": {
"bool": { // (2)
"filter": [ // (3)
}
},
{
"term": { // (5)
"__typeName.keyword": {
"value": "Connection"
}
}
},
{
"term": { // (6)
"name.keyword": {
"value": "production"
}
}
},
{
"term": { // (7)
"connectorName": {
"value": "snowflake"
}
}
}
]
}
},
"track_total_hits": true
},
"suppressLogs": true,
"showSearchScore": false,
"excludeMeanings": false,
"excludeClassifications": false
}
- Run a search to find the connections.
- To start building up a query with multiple conditions, you can use a
boolquery in Elasticsearch. - You can use the
filtercriteria to define all the conditions the search results must match in a binary way (either matches or doesn't). This avoids the need to calculate a score for each result. - Searches by default will return all assets that are found—whether active or archived (soft-deleted). In most cases, you probably only want the active ones.
- Since there could be tables, views, materialized views, columns, databases, schemas, etc in this connection—but you only want the connection itself—you can use an exact match on the type to restrict results to only connections.
- Exact match search (case-sensitive) on the name of the connection.
- Exact match search on the type of the connector for the connection.
All connections
On the other hand, you may want to find all the connections that exist in the environment:
- Java
- Python
- Kotlin
- Raw REST API
Connection.select(client) // (1)
.pageSize(100) // (2)
.stream() // (3)
.filter(a -> a instanceof Connection) // (4)
.forEach(c -> { // (5)
log.info("Connection: {}", c);
});
- To start building up a query to include all connections, you can use the
select()convenience method onConnectionitself. This will already limit results to only active (non-archived) connections. Because this operation will directly search for the asset in Atlan, you must provide it anAtlanClientthrough which to connect to the tenant. - (Optional) You can chain a
pageSize()method to control the page sizes, to further limit API calls by retrieving more results per page. - The search will only run when you call the
stream()method, which will then lazily-load each page of results into a stream. - (Optional) You can do any other operations you might do on a stream, such as filtering the results to make sure they're of a certain type.
- This is the pattern for iterating through all results (across pages) covered in the Searching for assets portion of the SDK documentation.
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import Connection
from pyatlan.model.fluent_search import FluentSearch, CompoundQuery
client = AtlanClient() # (1)
request = (
FluentSearch() # (2)
.where(CompoundQuery.asset_type(Connection)) # (3)
.where(CompoundQuery.active_assets()) # (4)
.page_size(100) # (5)
).to_request() # (6)
for result in client.asset.search(request): # (7)
if isinstance(result, Connection): # (8)
print(result)
- 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
FluentSearchobject. - The
.where()method allows you to limit to only certain assets. In this example, we're looking for connections, so use theCompoundQuery.asset_type()helper to narrow to only connections. - You can chain additional
.where()methods to add further conditions, like this example where we limit to only active (non-archived) assets. - (Optional) You can chain a
pageSize()method to control the page sizes, to further limit API calls by retrieving more results per page. - 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.
- Use the
isinstancemethod to make sure that the asset is of the desired type. This will also allow an IDE to provide specific type hints for this asset type.
Connection.select(client) // (1)
.pageSize(100) // (2)
.stream() // (3)
.filter { it is Connection } // (4)
.forEach { // (5)
log.info { "Connection: $it" }
}
- To start building up a query to include all connections, you can use the
select()convenience method onConnectionitself. This will already limit results to only active (non-archived) connections. Because this operation will directly search for the asset in Atlan, you must provide it anAtlanClientthrough which to connect to the tenant. - (Optional) You can chain a
pageSize()method to control the page sizes, to further limit API calls by retrieving more results per page. - The search will only run when you call the
stream()method, which will then lazily-load each page of results into a stream. - (Optional) You can do any other operations you might do on a stream, such as filtering the results to make sure they're of a certain type.
- This is the pattern for iterating through all results (across pages) covered in the Searching for assets portion of the SDK documentation.
{
"dsl": { // (1)
"from": 0,
"size": 100,
"query": {
"bool": { // (2)
"filter": [ // (3)
}
},
{
"term": {
"__state": { // (5)
"value": "ACTIVE"
}
}
}
]
}
},
"track_total_hits": true
},
"suppressLogs": true,
"showSearchScore": false,
"excludeMeanings": false,
"excludeClassifications": false
}
-
Run a search to find the connections.
-
To start building up a query with multiple conditions, you can use a
boolquery in Elasticsearch. -
You can use the
filtercriteria to define all the conditions the search results must match in a binary way (either matches or doesn't). This avoids the need to calculate a score for each result. -
You can use an exact match on the type to restrict results to only connections.
-
Searches by default will return all assets that are found—whether active or archived (soft-deleted). In most cases, you probably only want the active ones.
Columns in schema
This example finds all columns that exist in a particular schema—irrespective of the table, view, or materialized view they exist within.
- Java
- Python
- Kotlin
- Raw REST API
String schemaQN = "default/snowflake/1662194632/MYDB/MY_SCH"; // (1)
Column.select(client) // (2)
.where(Asset.QUALIFIED_NAME.startsWith(schemaQN)) // (3)
.pageSize(100) // (4)
.includeOnResults(Asset.DESCRIPTION) // (5)
.stream() // (6)
.filter(a -> a instanceof Column) // (7)
.forEach(c -> { // (8)
log.info("Column: {}", c);
});
- Part of the trick here is that the
qualifiedNameof a column starts with thequalifiedNameof its parent (table, view or materialized view). Similarly, thequalifiedNameof the table, view or materialized view starts with thequalifiedNameof its parent schema. (And so on, all the way up to the connection itself.) - To start building up a query specifically for columns, you can use the
select()convenience method onColumnitself. Because this operation will directly search for the asset in Atlan, you must provide it anAtlanClientthrough which to connect to the tenant. - You can use the
where()method to define all the conditions the search results must match. For this example, use theAsset.QUALIFIED_NAMEconstant to limit to only those assets whosequalifiedNamestarts with thequalifiedNameof the schema (by using thestartsWith()predicate). In this example, that means only assets that are within this particular schema will be returned as results. - (Optional) You can play around with different page sizes, to further limit API calls by retrieving more results per page.
- Add as many attributes as needed. Each attribute you add here will make sure that detail is included in each search result. So in this example, every column will include its description. (Limit these attributes to the minimum you need about each column to do your intended work.)
- The search will only run when you call the
stream()method, which will then lazily-load each page of results into a stream. - (Optional) You can do any other operations you might do on a stream, such as filtering the results to make sure they're of a certain type.
- This is the pattern for iterating through all results (across pages) covered in the Searching for assets portion of the SDK documentation.
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import Column
from pyatlan.model.fluent_search import FluentSearch, CompoundQuery
schema_qn = "default/snowflake/1646836521/ATLAN_SAMPLE_DATA/PUBLIC" # (1)
client = AtlanClient() # (2)
request = (
FluentSearch() # (3)
.where(CompoundQuery.asset_type(Column)) # (4)
.where(CompoundQuery.active_assets()) # (5)
.where(Column.QUALIFIED_NAME.startswith(schema_qn)) # (6)
).to_request() # (7)
for result in client.asset.search(request): # (8)
if isinstance(result, Column): # (9)
print(result)
- Part of the trick here is that the
qualified_nameof a column starts with thequalified_nameof its parent (table, view or materialized view). Similarly, thequalified_nameof the table, view or materialized view starts with thequalified_nameof its parent schema. (And so on, all the way up to the connection itself.) - 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
FluentSearchobject. - The
.where()method allows you to limit to only certain assets. In this example, we're looking for columns, so use theCompoundQuery.asset_type()helper to narrow to only columns. - You can chain additional
.where()methods to add further conditions, like this example where we limit to only active (non-archived) assets. - For this example, use the
Column.QUALIFIED_NAMEconstant to limit to only those columns whosequalified_namestarts with thequalified_nameof the schema (by using thestartswith()predicate). In this example, that means only columns that are within this particular schema will be returned as results. - 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.
- Use the
isinstancemethod to make sure that the asset is of the desired type. This will also allow an IDE to provide specific type hints for this asset type.
val schemaQN = "default/snowflake/1662194632/MYDB/MY_SCH" // (1)
Column.select(client) // (2)
.where(Asset.QUALIFIED_NAME.startsWith(schemaQN)) // (3)
.pageSize(100) // (4)
.includeOnResults(Asset.DESCRIPTION) // (5)
.stream() // (6)
.filter { it is Column } // (7)
.forEach { // (8)
log.info { "Column: $it" }
});
- Part of the trick here is that the
qualifiedNameof a column starts with thequalifiedNameof its parent (table, view or materialized view). Similarly, thequalifiedNameof the table, view or materialized view starts with thequalifiedNameof its parent schema. (And so on, all the way up to the connection itself.) - To start building up a query specifically for columns, you can use the
select()convenience method onColumnitself. Because this operation will directly search for the asset in Atlan, you must provide it anAtlanClientthrough which to connect to the tenant. - You can use the
where()method to define all the conditions the search results must match. For this example, use theAsset.QUALIFIED_NAMEconstant to limit to only those assets whosequalifiedNamestarts with thequalifiedNameof the schema (by using thestartsWith()predicate). In this example, that means only assets that are within this particular schema will be returned as results. - (Optional) You can play around with different page sizes, to further limit API calls by retrieving more results per page.
- Add as many attributes as needed. Each attribute you add here will make sure that detail is included in each search result. So in this example, every column will include its description. (Limit these attributes to the minimum you need about each column to do your intended work.)
- The search will only run when you call the
stream()method, which will then lazily-load each page of results into a stream. - (Optional) You can do any other operations you might do on a stream, such as filtering the results to make sure they're of a certain type.
- This is the pattern for iterating through all results (across pages) covered in the Searching for assets portion of the SDK documentation.
{
"dsl": { // (1)
"query": {
"bool": { // (2)
"filter": [ // (3)
}
},
{
"term": { // (5)
"__typeName.keyword": {
"value": "Column"
}
}
},
{
"term": { // (6)
"__state": {
"value": "ACTIVE"
}
}
}
]
}
},
"from": 0, // (7)
"size": 100,
"track_total_hits": true
},
"attributes": [ // (8)
"description"
],
"suppressLogs": true,
"showSearchScore": false,
"excludeMeanings": false,
"excludeClassifications": false
}
-
Run a search to find the columns.
-
To start building up a query with multiple conditions, you can use a
boolquery in Elasticsearch. -
You can use the
filtercriteria to define all the conditions the search results must match in a binary way (either matches or doesn't). This avoids the need to calculate a score for each result. -
Part of the trick here is that the
qualifiedNameof a column starts with thequalifiedNameof its parent (table, view or materialized view). Similarly, thequalifiedNameof the table, view or materialized view starts with thequalifiedNameof its parent schema. (And so on, all the way up to the connection itself.) -
Since there could be tables, views, materialized views and columns in this schema—but you only want columns—you can use an exact match on the type to restrict results to only columns.
-
Searches by default will return all assets that are found—whether active or archived (soft-deleted). In most cases, you probably only want the active ones.
-
Here you can play around with different page sizes, to further limit API calls by retrieving more results per page.
-
Add as many attributes as needed. Each attribute you add here will make sure that detail is included in each search result. So in this example, every column will include its description. (Limit these attributes to the minimum you need about each column to do your intended work.)
Assets with custom metadata
This example finds all assets with a particular custom metadata attribute populated—irrespective of the specific value of the attribute.
- Java
- Python
- Kotlin
- Raw REST API
client.assets.select() // (1)
.where(CustomMetadataField.of(client, "RACI", "Responsible").hasAnyValue()) // (2)
._includesOnResults(client.getCustomMetadataCache().getAttributesForSearchResults("RACI")) // (3)
.stream() // (4)
.forEach(a -> { // (5)
log.info("Asset: {}", a);
});
-
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
CustomMetadataFieldto 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. (TheCustomMetadataFieldwill 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 theRACIcustom 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.
:::
4. The search will only run when you call the stream() method, which will then lazily-load each page of results into a stream.
5. This is the pattern for iterating through all results (across pages) covered in the Searching for assets portion of the SDK documentation.
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.fields.atlan_fields import CustomMetadataField
from pyatlan.model.fluent_search import FluentSearch
client = AtlanClient() # (1)
request = (
FluentSearch(_includes_on_results=client.custom_metadata_cache.get_attributes_for_search_results("RACI")) # (2)
.where(CustomMetadataField(client=client, set_name="RACI", attribute_name="Responsible").has_any_value()) # (3)
).to_request() # (4)
for result in client.asset.search(request): # (5)
print(result)
-
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
FluentSearchobject.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 theRACIcustom 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.
:::
3. 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. (The CustomMetadataField 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.
client.assets.select() // (1)
.where(CustomMetadataField.of(client, "RACI", "Responsible").hasAnyValue()) // (2)
._includesOnResults(client.customMetadataCache.getAttributesForSearchResults("RACI")) // (3)
.stream() // (4)
.forEach { // (5)
log.info { "Asset: $it" }
}
-
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
CustomMetadataFieldto 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. (TheCustomMetadataFieldwill 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 theRACIcustom 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.
:::
4. The search will only run when you call the stream() method, which will then lazily-load each page of results into a stream.
5. This is the pattern for iterating through all results (across pages) covered in the Searching for assets portion of the SDK documentation.
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.
{
"dsl": { // (1)
"query": { // (2)
"exists": { // (3)
"field": "omrIzGB4oYlZrFKfTIUz6D" // (4)
}
},
"track_total_hits": true
},
"attributes": [
"UQot6bU4XcGcIx8gAQ1dsW.omrIzGB4oYlZrFKfTIUz6D" // (5)
],
"suppressLogs": true,
"showSearchScore": false,
"excludeMeanings": false,
"excludeClassifications": false
}
- 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
existscriteria 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.
Assets with specific custom metadata value
This example finds all assets with a particular custom metadata attribute populated—with a specific value for the attribute.
- Java
- Python
- Kotlin
- Raw REST API
client.assets.select() // (1)
.where(CustomMetadataField.of(client, "RACI", "Responsible").eq("This exact value", false)) // (2)
._includesOnResults(client.getCustomMetadataCache().getAttributesForSearchResults("RACI")) // (3)
.stream() // (4)
.forEach(a -> { // (5)
log.info("Asset: {}", a);
});
-
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
CustomMetadataFieldto 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. (TheCustomMetadataFieldwill 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 (and in the case of a string value, you must supply a second parameter indicating whether the search should be case-sensitive (false) or case-insensitive (true)). -
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 theRACIcustom 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.
:::
4. The search will only run when you call the stream() method, which will then lazily-load each page of results into a stream.
5. This is the pattern for iterating through all results (across pages) covered in the Searching for assets portion of the SDK documentation.
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.fields.atlan_fields import CustomMetadataField
from pyatlan.model.fluent_search import FluentSearch
client = AtlanClient() # (1)
request = (
FluentSearch(_includes_on_results=client.custom_metadata_cache.get_attributes_for_search_results("RACI")) # (2)
.where(CustomMetadataField(client=client, set_name="RACI", attribute_name="Responsible").eq("This exact value")) # (3)
).to_request() # (4)
for result in client.asset.search(request): # (5)
print(result)
-
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
FluentSearchobject.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 theRACIcustom 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.
:::
3. 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. (The CustomMetadataField 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.
client.assets.select() // (1)
.where(CustomMetadataField.of(client, "RACI", "Responsible").eq("This exact value", false)) // (2)
._includesOnResults(client.customMetadataCache.getAttributesForSearchResults("RACI")) // (3)
.stream() // (4)
.forEach { // (5)
log.info { "Asset: $it" }
}
-
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
CustomMetadataFieldto 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. (TheCustomMetadataFieldwill 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 (and in the case of a string value, you must supply a second parameter indicating whether the search should be case-sensitive (false) or case-insensitive (true)). -
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 theRACIcustom 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.
:::
4. The search will only run when you call the stream() method, which will then lazily-load each page of results into a stream.
5. This is the pattern for iterating through all results (across pages) covered in the Searching for assets portion of the SDK documentation.
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.
{
"dsl": { // (1)
"query": { // (2)
"term": { // (3)
"omrIzGB4oYlZrFKfTIUz6D": { // (4)
"value": "This exact value" // (5)
}
}
},
"track_total_hits": true
},
"attributes": [
"UQot6bU4XcGcIx8gAQ1dsW.omrIzGB4oYlZrFKfTIUz6D" // (6)
],
"suppressLogs": true,
"showSearchScore": false,
"excludeMeanings": false,
"excludeClassifications": false
}
- 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
termquery 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.
Assets linked to term
This example finds all assets that are linked to a specific glossary term. (And could be extended to do find assets linked to any one of a number of glossary terms.) In this specific example we will find any assets linked to a glossary term named Revenue in a glossary named Metrics.
To find the assets linked to the glossary term, you'll need to search using the qualifiedName of the term. This isn't the human-readable name you see in the UI. So this example is split into two parts:
- Finding the
qualifiedNameof the glossary term from its human-readable name and the result of (1). - Finding all assets linked to that glossary term.
For example:
- Java
- Python
- Kotlin
- Raw REST API
GlossaryTerm term = GlossaryTerm.findByName(client, "Revenue", "Concepts"); // (1)
String termQualifiedName = term.getQualifiedName(); // (2)
- The
GlossaryTerm.findByName()helper method will retrieve the glossary term by its human-readable name, given the name of the glossary in which it should exist. If the term doesn't exist (within that glossary), it will throw aNotFoundException. Because this operation will directly search for the asset in Atlan, you must provide it anAtlanClientthrough which to connect to the tenant. - If no exception was thrown, you can retrieve the qualifiedName of the glossary term.
client.assets.select() // (1)
.where(Asset.ASSIGNED_TERMS.in(List.of(termQualifiedName))) // (2)
.stream() // (3)
.forEach(a -> { // (4)
log.info("Asset: {}", a);
});
- To search across all assets, you can use the
assets.select()convenience method on a client. - When searching for assets linked to one or more terms, you need to use the
qualifiedNameof the terms. (This example shows searching for just one term, but you could search for any number of them in the list. The search will find assets that are assigned at least one of those terms in the list.) - 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.
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.fluent_search import FluentSearch, CompoundQuery
client = AtlanClient() # (1)
term = client.asset.find_term_by_name("Revenue", "Concepts") # (2)
term_qualified_name = term.qualified_name # (3)
- Start with a client to run the search through. For the default client, you can always use
AtlanClient(). - The
asset.find_term_by_name()helper method will retrieve the glossary term by its human-readable name, given the name of the glossary in which it should exist. If the term doesn't exist (within that glossary), it will throw aNotFoundError. - If no exception was thrown, you can retrieve the
qualified_nameof the glossary term.
request = (
FluentSearch() # (1)
.where(CompoundQuery.assigned_term([term_qualified_name])) # (2)
).to_request() # (3)
for result in client.asset.search(request): # (4)
print(result)
- To search across all assets, you can use a
FluentSearchobject. - When searching for assets linked to a given term, you need to use the
qualified_nameof the term. - 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.
val term = GlossaryTerm.findByName(client, "Revenue", "Concepts") // (1)
val termQualifiedName = term.qualifiedName // (2)
- The
GlossaryTerm.findByName()helper method will retrieve the glossary term by its human-readable name, given the name of the glossary in which it should exist. If the term doesn't exist (within that glossary), it will throw aNotFoundException. Because this operation will directly search for the asset in Atlan, you must provide it anAtlanClientthrough which to connect to the tenant. - If no exception was thrown, you can retrieve the qualifiedName of the glossary term.
client.assets.select() // (1)
.where(Asset.ASSIGNED_TERMS.`in`(listOf(termQualifiedName))) // (2)
.stream() // (3)
.forEach { // (4)
log.info { "Asset: $it" }
}
- To search across all assets, you can use the
assets.select()convenience method on a client. - When searching for assets linked to one or more terms, you need to use the
qualifiedNameof the terms. (This example shows searching for just one term, but you could search for any number of them in the list. The search will find assets that are assigned at least one of those terms in the list.) - 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.
Before you can search for assets linked to a term, you first need to have the qualifiedName of the term. You will likely need to first find the term by its name.
{
"dsl": { // (1)
"query": { // (2)
"terms": { // (3)
"__meanings": [ // (4)
"5h2wMbSbWtRN1V1b05Mtb@LD5Tb30qbuYCZKsmFRpmS" // (5)
]
}
},
"track_total_hits": true
},
"suppressLogs": true,
"showSearchScore": false,
"excludeMeanings": false,
"excludeClassifications": false
}
- 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
termsquery to exactly match a value on assets, for a given field, against a list of possible matches. - To find terms, match against the
__meaningsfield. - Provide the exact value of the
qualifiedNamefor the term for which you want to find linked assets.
Assets with 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.
- Java
- Python
- Kotlin
- Raw REST API
client.assets.select() // (1)
.tagged(List.of("PII")) // (2)
.stream() // (3)
.forEach(a -> { // (4)
log.info("Asset: {}", a);
});
- To search across all assets, you can use the
assets.select()convenience method on a client. - The
.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.
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.fluent_search import FluentSearch, CompoundQuery
client = AtlanClient() # (1)
request = (
FluentSearch() # (2)
.where(CompoundQuery.tagged(client=client, with_one_of=["PII"])) # (3)
).to_request() # (4)
for result in client.asset.search(request): # (5)
print(result)
- 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
FluentSearchobject. - 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.
client.assets.select() // (1)
.tagged(listOf("PII")) // (2)
.stream() // (3)
.forEach { // (4)
log.info { "Asset: $it" }
}
- 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
.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.
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.
{
"dsl": { // (1)
"query": {
"bool": { // (2)
"minimum_should_match": "1", // (3)
"should": [ // (4)
},
{
"terms": {
"__propagatedTraitNames": [ // (6)
"wAI4bROOqCQzES8HCNso9F" // (7)
]
}
}
]
}
},
"track_total_hits": true
},
"suppressLogs": true,
"showSearchScore": false,
"excludeMeanings": false,
"excludeClassifications": false
}
- 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
boolquery 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
__traitNamesto match directly-classified assets. - Use the Atlan-internal hashed-string representation of the Atlan tag.
- Use
__propagatedTraitNamesto match assets that have been propagated this Atlan tag. - Once again, use the Atlan-internal hashed-string representation of the Atlan tag.
Assets with source tag
This example finds all assets that are assigned a specific source tag.
- Java
- Python
- Kotlin
- Raw REST API
client.assets.select() // (1)
.taggedWithValue( // (2)
"Sensitivity", // (3)
"Highly Restricted", // (4)
true // (5)
)
.stream() // (6)
.forEach(a -> { // (7)
log.info("Asset: {}", a);
});
- To search across all assets, you can use the
assets.select()convenience method on a client. - The
.taggedWithValue()helper method allows us to limit to assets that match having this particular tag and value combination. - You must specify the human-readable name of the Atlan tag that's mapped to a source tag. 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 must also provide the value you want to match.
- (Optional) You can restrict the search to only directly-tagged assets with the value using
true, or look for all assets tagged with the value (whether directly or propagated). - 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.
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets.core.asset import Asset
from pyatlan.model.fluent_search import CompoundQuery, FluentSearch
client = AtlanClient() # (1)
request = (
FluentSearch()
.select() # (2)
.where(CompoundQuery.tagged_with_value( # (3)
client=client, # (4)
atlan_tag_name="Confidential", # (5)
value="Highly Restricted", # (6)
directly=True, # (7)
source_tag_qualified_name="default/snowflake/1711669993/ANALYTICS/PRODUCTION/CONFIDENTIAL", # (8)
)
)
).to_request() # (9)
response = client.asset.search(request) # (10)
for asset in response: # (11)
...
- Start with a client to run the search through.
- To search across all active assets, you can use the
FluentSearch.select()method. - The
CompoundQuery.tagged_with_value()helper method allows. us to limit to assets that match having this particular tag and value combination. - You must provide a client instance.
- You must specify the human-readable name of the Atlan tag that's mapped to a source tag. 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 must also provide the value you want to match.
- (Optional) You can restrict the search to only directly-tagged assets
with the value using
True, or look for all assets tagged with the value (whether directly or propagated) (False). - (Optional) You can specify which source tag qualified name to use when multiple mapped
source-synced tagsare found. - Now convert the given
FluentSearchinto anIndexSearchRequestobject for the search. - The search will only run when you call the
client.asset.search()method. - This is the pattern for iterating through all results (across pages) covered in the Searching for assets portion of the SDK documentation.
client.assets.select() // (1)
.taggedWithValue( // (2)
"Sensitivity", // (3)
"Highly Restricted", // (4)
true // (5)
)
.stream() // (6)
.forEach { // (7)
log.info { "Asset: $it" }
}
- To search across all assets, you can use the
assets.select()convenience method on a client. - The
.taggedWithValue()helper method allows us to limit to assets that match having this particular tag and value combination. - You must specify the human-readable name of the Atlan tag that's mapped to a source tag. 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 must also provide the value you want to match.
- (Optional) You can restrict the search to only directly-tagged assets with the value using
true, or look for all assets tagged with the value (whether directly or propagated). - 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.
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.
{
"dsl": { // (1)
"query": {
"bool": { // (2)
"filter": [
{
"term": {
"__traitNames": { // (3)
"value": "Z96sGJrF0S68PxYTUdKG6b", // (4)
"case_insensitive": false
}
}
},
{
"span_within": { // (5)
"big": {
"span_near": {
"clauses": [
{
"span_term": {
"__classificationsText.text": { // (6)
"value": "Z96sGJrF0S68PxYTUdKG6b"
}
}
},
{
"span_term": {
"__classificationsText.text": { // (7)
"value": "default/snowflake/1726834662/ANALYTICS/WIDE_WORLD_IMPORTERS/CONFIDENTIAL"
}
}
}
],
"in_order": true,
"slop": 10000000
}
},
"little": {
"span_near": {
"clauses": [
{
"span_term": {
"__classificationsText.text": { // (8)
"value": "tagAttachmentValue"
}
}
},
{
"span_term": {
"__classificationsText.text": {
"value": "Highly" // (9)
}
}
},
{
"span_term": {
"__classificationsText.text": {
"value": "Restricted"
}
}
},
{
"span_term": {
"__classificationsText.text": {
"value": "tagAttachmentKey" // (10)
}
}
}
],
"in_order": true,
"slop": 0
}
}
}
}
]
}
},
"track_total_hits": true
},
"suppressLogs": true,
"showSearchScore": false,
"excludeMeanings": false,
"excludeClassifications": false
}
- Run a search to find the assets.
- To match assets that are directly assigned the Atlan tag, use a
boolquery for multiple conditions. - Use
__traitNamesto match directly-classified assets. - Use the Atlan-internal hashed-string representation of the Atlan tag.
- To match a source tag, you must use a
span_withinquery that has this exact structure. - Once again, everywhere you specify the Atlan tag you must use the Atlan-internal hashed-string representation of the Atlan tag.
- You must also specify the
qualifiedNameof the source Tag asset. - When matching a value, you must specify these
little.span_nearclauses in exactly the order shown in this example, starting withtagAttachmentValue. - The value itself should come next, but note that if there are any spaces in the value then you must specify a
span_termfor each individual word of the value. - Finally you must specify a
span_termoftagAttachmentKeyas the final clause.
Deprecated assets
This example finds all assets that are marked as deprecated.
- Java
- Python
- Kotlin
- Raw REST API
client.assets.select() // (1)
.where(Asset.CERTIFICATE_STATUS.eq(CertificateStatus.DEPRECATED)) // (2)
.stream() // (3)
.forEach(a -> { // (4)
log.info("Asset: {}", a);
});
-
To search across all assets, you can use the
assets.select()convenience method on a client. -
The
.where()method allows you to limit to only assets that have a particular value in a particular field. In this example, we're looking for values for the certificate status, so useAsset.CERTIFICATE_STATUS.Since we only want assets that are deprecated, we will query where that certificate is set to the
CertificateStatus.DEPRECATEDvalue. (No need to try to remember or ever even know what the precise string values for the certificates are—we've provided enums for them in the SDK.) -
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.
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import Asset
from pyatlan.model.enums import CertificateStatus
from pyatlan.model.fluent_search import FluentSearch
client = AtlanClient() # (1)
request = (
FluentSearch() # (2)
.where(Asset.CERTIFICATE_STATUS.eq(CertificateStatus.DEPRECATED.value)) # (3)
).to_request() # (4)
for result in client.asset.search(request): # (5)
print(result)
-
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
FluentSearchobject. -
The
.where()method allows you to limit to only assets that have a particular value in a particular field. In this example, we're looking for values for the certificate status, so useAsset.CERTIFICATE_STATUS.Since we only want assets that are deprecated, we will query where that certificate is set to the
CertificateStatus.DEPRECATEDvalue. (No need to try to remember or ever even know what the precise string values for the certificates are—we've provided enums for them in the SDK.) -
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.
client.assets.select() // (1)
.where(Asset.CERTIFICATE_STATUS.eq(CertificateStatus.DEPRECATED)) // (2)
.stream() // (3)
.forEach { // (4)
log.info { "Asset: $it" }
}
-
To search across all assets, you can use the
assets.select()convenience method on a client. -
The
.where()method allows you to limit to only assets that have a particular value in a particular field. In this example, we're looking for values for the certificate status, so useAsset.CERTIFICATE_STATUS.Since we only want assets that are deprecated, we will query where that certificate is set to the
CertificateStatus.DEPRECATEDvalue. (No need to try to remember or ever even know what the precise string values for the certificates are—we've provided enums for them in the SDK.) -
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.
Before you can search for classifications, you first need to have the Atlan-internal hashed-string representation of the classification. You will likely need to first retrieve the hashed-string representation.
{
"dsl": { // (1)
"query": { // (2)
"term": { // (3)
"certificateStatus": { // (4)
"value": "DEPRECATED" // (5)
}
}
},
"track_total_hits": true
},
"suppressLogs": true,
"showSearchScore": false,
"excludeMeanings": false,
"excludeClassifications": false
}
- 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
termquery to exactly match a value on assets, for a given field. - Use the name of the field you want to match. In this example, since you want to match a specific certificate, you can use the
certificateStatusfield. - Provide the exact value you want to match in that field. In this example, you will be matching only assets with a certificate of
DEPRECATED.
Certified but incomplete assets
This example finds all assets that are marked as verified, but are missing a description—suggesting they're in fact incomplete.
- Java
- Python
- Kotlin
- Raw REST API
client.assets.select() // (1)
.where(Asset.CERTIFICATE_STATUS.eq(CertificateStatus.VERIFIED)) // (2)
.whereNot(Asset.DESCRIPTION.hasAnyValue()) // (3)
.whereNot(Asset.USER_DESCRIPTION.hasAnyValue())
.includeOnResults(Asset.OWNER_USERS) // (4)
.includeOnResults(Asset.OWNER_GROUPS) // (5)
.stream() // (6)
.forEach(a -> { // (7)
log.info("Asset: {}", a);
});
-
To search across all assets, you can use the
assets.select()convenience method on a client. -
The
where()helper method allows us to limit to only assets that meet a a particular condition. In this example, we're looking for values for the certificate status, so useAsset.CERTIFICATE_STATUS. (No need to try to remember or ever even know what the precise string value is for the name of this field—we've provided enums for them in the SDK.)Since we only want assets that are verified, we will query where that certificate is set to the
CertificateStatus.VERIFIEDvalue. (No need to try to remember or ever even know what the precise string values for the certificates are—we've provided enums for them in the SDK.) -
You can use the
whereNot()method to do the opposite—define all the conditions the search results must not match. Here we're limiting to only assets that have a description populated.The
hasAnyValue()predicate method allows us to limit to only assets that have a user-defined description populated. In Atlan you have bothdescription(crawled from source) anduserDescription(user-defined or overridden). For this example use case, you probably want to check that both of these are empty. -
As part of the search, you may want certain details included in every result. In this use case, you may want to know the asset owner—someone to confirm this should really be certified when there is no description.
-
In Atlan you have both users and groups that can own assets. For this example use case, you probably want to retrieve both of these for every result.
-
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.
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import Asset
from pyatlan.model.enums import CertificateStatus
from pyatlan.model.fluent_search import FluentSearch
client = AtlanClient() # (1)
request = (
FluentSearch() # (2)
.where(Asset.CERTIFICATE_STATUS.eq(CertificateStatus.VERIFIED.value)) # (3)
.where_not(Asset.DESCRIPTION.has_any_value()) # (4)
.where_not(Asset.USER_DESCRIPTION.has_any_value())
.include_on_results(Asset.OWNER_USERS) # (5)
.include_on_results(Asset.OWNER_GROUPS) # (6)
).to_request() # (7)
for result in client.asset.search(request): # (8)
print(result)
-
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
FluentSearchobject. -
The
.where()method allows you to limit to only assets that have a particular value in a particular field. In this example, we're looking for values for the certificate status, so useAsset.CERTIFICATE_STATUS.Since we only want assets that are verified, we will query where that certificate is set to the
CertificateStatus.VERIFIEDvalue. (No need to try to remember or ever even know what the precise string values for the certificates are—we've provided enums for them in the SDK.) -
You can use the
.where_not()method to do the opposite—define all the conditions the search results must not match. Here we're limiting to only assets that have a description populated.The
has_any_value()predicate method allows us to limit to only assets that have a user-defined description populated. In Atlan you have bothdescription(crawled from source) anduserDescription(user-defined or overridden). For this example use case, you probably want to check that both of these are empty. -
As part of the search, you may want certain details included in every result. In this use case, you may want to know the asset owner—someone to confirm this should really be certified when there is no description.
-
In Atlan you have both users and groups that can own assets. For this example use case, you probably want to retrieve both of these for every result.
-
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.
client.assets.select() // (1)
.where(Asset.CERTIFICATE_STATUS.eq(CertificateStatus.VERIFIED)) // (2)
.whereNot(Asset.DESCRIPTION.hasAnyValue()) // (3)
.whereNot(Asset.USER_DESCRIPTION.hasAnyValue())
.includeOnResults(Asset.OWNER_USERS) // (4)
.includeOnResults(Asset.OWNER_GROUPS) // (5)
.stream() // (6)
.forEach { // (7)
log.info { "Asset: $it" }
}
-
To search across all assets, you can use the
assets.select()convenience method on a client. -
The
where()helper method allows us to limit to only assets that meet a a particular condition. In this example, we're looking for values for the certificate status, so useAsset.CERTIFICATE_STATUS. (No need to try to remember or ever even know what the precise string value is for the name of this field—we've provided enums for them in the SDK.)Since we only want assets that are verified, we will query where that certificate is set to the
CertificateStatus.VERIFIEDvalue. (No need to try to remember or ever even know what the precise string values for the certificates are—we've provided enums for them in the SDK.) -
You can use the
whereNot()method to do the opposite—define all the conditions the search results must not match. Here we're limiting to only assets that have a description populated.The
hasAnyValue()predicate method allows us to limit to only assets that have a user-defined description populated. In Atlan you have bothdescription(crawled from source) anduserDescription(user-defined or overridden). For this example use case, you probably want to check that both of these are empty. -
As part of the search, you may want certain details included in every result. In this use case, you may want to know the asset owner—someone to confirm this should really be certified when there is no description.
-
In Atlan you have both users and groups that can own assets. For this example use case, you probably want to retrieve both of these for every result.
-
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.
{
"dsl": { // (1)
"query": {
"bool": { // (2)
"filter": [ // (3)
}
}
],
"must_not": [ // (5)
},
{
"exists": {
"field": "userDescription"
}
}
]
}
},
"track_total_hits": true
},
"attributes": [
"ownerUsers", // (6)
"ownerGroups" // (7)
],
"suppressLogs": true,
"showSearchScore": false,
"excludeMeanings": false,
"excludeClassifications": false
}
-
Run a search to find the columns.
-
To start building up a query with multiple conditions, you can use a
boolquery in Elasticsearch. -
You can use the
filtercriteria to define all the conditions the search results must match in a binary way (either matches or doesn't). This avoids the need to calculate a score for each result. -
In this example, you are looking for verified assets. So you can begin by filtering only those assets with a
certificateStatusofVERIFIED. -
Since you want to find assets that specifically do not have other characteristics, use the
must_notcriteria to specify these. Specifically, match assets that do not have either adescriptionoruserDescriptionpopulated. -
As part of the search, you may want certain details included in every result. In this use case, you may want to know the asset owner—someone to confirm this should really be certified when there is no description.
The Models section of the site details all the attributes that exist in each different type of asset, and therefore which ones you can retrieve as additional details in each search result, like ownerUsers.
- In Atlan you have both users and groups that can own assets. For this example use case, you probably want to retrieve both of these for every result.
The Models section of the site details all the attributes that exist in each different type of asset, and therefore which ones you can retrieve as additional details in each search result, like ownerGroups.
Assets with long descriptions
When text exceeds a particular length (5K characters), the keyword field on an attribute can be empty while the text field on the same attribute is populated. For KeywordTextField types (like DESCRIPTION or USER_DESCRIPTION), use field_type=AtlanSearchableFieldType.TEXT to check the text field instead.
- Java
- Python
- Kotlin
- Raw REST API
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import Asset
from pyatlan.model.enums import AtlanSearchableFieldType
from pyatlan.model.fluent_search import FluentSearch
client = AtlanClient() # (1)
request = (
FluentSearch() # (2)
.where(Asset.DESCRIPTION.has_any_value(field_type=AtlanSearchableFieldType.TEXT)) # (3)
.include_on_results(Asset.DESCRIPTION) # (4)
).to_request() # (5)
for result in client.asset.search(request): # (6)
print(result)
- 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
FluentSearchobject. - The
has_any_value()predicate withfield_type=AtlanSearchableFieldType.TEXTchecks the text field rather than the keyword field. This is important when searching for assets with long descriptions (>5K characters), as the keyword field may be empty while the text field contains the content. - Include the description in the results to see the actual content.
- 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.
{
"dsl": {
"query": {
"exists": { "field": "description" }
}
}
}