Skip to main content

Transform search results

Learn how to search for objects and return transformed properties

Data types can have transformations. Vault provides several built-in transformations. For example, there is a transformation for the email data type that returns a masked email address similar to this ‘j**********@gmail.com’.

To get transformed values of objects you search for you:

  1. Determine which transformed property values you want from each object.
  2. Use CLI search objects or the REST API search objects operation passing the search criteria, the transformed properties, and collection name.
note

This guide illustrate returning transformed results from a string search, the same technique can be used for all search types available in Piiano Vault.

Step-by-step

You want to return the name and transformed email address for all buyers with the name "John" in the ‘buyers’ collection you created in Create a collection. First, build your search query, for example, like this:

name=John

Now, you determine the name of the transformation for email values.

Once you've determined the transformation name for the object property you want to retrieve, define the transformed property by appending the mask name to the property name using dot notation. For example, use email.mask for your transformed email address.

You now search for your buyers and retrieve the values and transformed values using the CLI like this:

pvault object query \
--match name=John \
--props name,email.mask \
--collection customers

You get a response similar to this:

Displaying 2 results.
+-----------------------------+------------+
| email.mask | name |
+-----------------------------+------------+
| m******@somemail.com | John |
| j*******@anotheremail.com | John |
+-----------------------------+------------+

The response is paginated. See CLI pagination for more information about working with paginated responses.

Or using the REST API like this:

curl -s -X POST \
--url 'http://localhost:8123/api/pvlt/1.0/data/collections/customers/query/objects?props=name,email.mask&reason=AppFunctionality' \
--header 'Authorization: Bearer pvaultauth' \
--header 'Content-Type: application/json' \
--data '{
"match": {"name":"John"}
}'

You get a response similar to this:

{
"results": [
{
"email": "m*******@somemail.com",
"name": "John"
},
{
"email": "j*******@anotheremail.com",
"name": "John"
}
],
"paging": {
"size": 2,
"remaining_count": 0,
"cursor": ""
}
}

The response is paginated. See API pagination for more information about working with paginated responses.

On this page