Skip to main content

2. Querying your Assets

In this section, we will learn how we can find and search our assets using the following approaches:

2.1 Using Asset URN or ID

Using the Asset URN or ID returned from when you are uploading your asset, you can easily find your asset like below

$ compass asset view main-postgres:my-database.orders

Response from the above query

{
"data": {
"id": "cebeb793-8933-434c-b38f-beb6dbad91a5",
"urn": "main-postgres:my-database.orders",
"type": "table",
"service": "postgres",
"name": "orders",
"description": "",
"data": {
"database": "my-database",
"namespace": "main-postgres"
},
"labels": null,
"owners": [],
"version": "0.2",
"updated_by": {
"uuid": "john.doe@example.com"
},
"changelog": [],
"created_at": "2021-03-22T22:45:11.160593Z",
"updated_at": "2021-03-22T22:45:11.160593Z"
}
}

2.2 Adding more assets

Before we try other APIs let's first add 5 additional assets to Compass.

curl --location --request PATCH 'http://localhost:8080/v1beta1/assets' \
--header 'Content-Type: application/json' \
--header 'Compass-User-UUID: john.doe@example.com' \
--data-raw '{
"asset": {
"urn": "main-postgres:my-database.products",
"type": "table",
"service": "postgres",
"name": "products",
"data": {
"database": "my-database",
"namespace": "main-postgres"
}
}
}
'

2.3 Using Search API

Search API is the preferred way when browsing through your assets in Compass. Let's see how powerful Compass is for discovering your assets.

Now that we have added more assets to Compass here, let's try to search for our newly added products table. To use Search API, we just need to provide a query/text/term.

Let's search for our products table using a typo query "podcts".

$ compass search "podcts"

Search results:

{
"data": [
{
"id": "7c0759f4-feec-4b5e-bf26-bf0d0b1236b1",
"urn": "main-postgres:my-database.products",
"type": "table",
"service": "postgres",
"name": "products",
"description": ""
}
]
}

Compass Search API supports fuzzy search, so even when you give "podcts", it will still be able to fetch your products table.

Conclusion

Search API is a really powerful discovery tool that you can leverage when storing your assets. It has lots of feature like fuzzy search which we just saw, you can also easily filter through asset's type, service and much more.

Up to this point, you have learnt how to create assets, inserting assets and querying them. Using these features, you can start leveraging Compass to be your Metadata Discovery Service.

Next we will see how you can use Compass to build a Lineage between your assets.