Tanzu Platform 10.0

Graph database search query construction in Tanzu Platform

Last Updated March 03, 2025

You can create search queries of the graph database in Tanzu Platform to locate particular resources you can work with in Tanzu Platform.

Property conditions

Your resource configurations are stored as properties and values of the resource object. For example, running EC2 instances have a property StateName with value running.

To locate resources with specific configurations, you can use the following property conditions.

ConditionSyntaxDescription
property with a valuepname = pvalueProperty with name pname has value equal to pvalue.
property different than a valuepname != pvalueProperty with name pname has value different than pvalue.
property existspn(pname) or propertyName(pname)There is a property with name pname.
property value existspv(pvalue) or propertyValue(pvalue)There is a property with value pvalue.

To apply the property conditions in your searches, use the following operators.

The operators are case-insensitive. The operator HAS and has might both be used.

OperatorUsage
HASApply one or more conditions to a resource type.
ANDGroup conditions when all of them must be satisfied.
ORGroup conditions when at least one of them must be satisfied.
NOTReverse a condition.
()Specify the order in which conditions are evaluated.

Tag condition

The tags you configure in your cloud provider can be accessed with the tag prefix. For example, use tag.createdBy to access the tag with name createdBy.

To locate resources by tag, you specify the following tag conditions.

ConditionSyntaxDescription
tag with a valuetag.tagname = tagvalueTag with name tagname has value equal to tagvalue.
tag different than a valuetag.tagname != tagvalueTag with name tagname has value different than tagvalue.
tag existstag.tagnameThere is a tag with name tagname.
tag value existstag = tagvalueThere is a tag with value tagvalue.

Tag conditions are applied using the same operators as property conditions and can be mixed and matched with property conditions.

Comparison operators with date and time functions

Comparison operators (<=, <, >, =>) are available for integer and datetime properties. In addition, some special date and time functions are available to construct dates easily.

SyntaxDescription
hoursAgo(n)Returns the time n hours earlier than now.
daysAgo(n)Returns the time n days earlier than now.
monthsAgo(n)Returns the time n months earlier than now.
yearsAgo(n)Returns the time n years earlier than now.

Wildcards

To find resource matching a pattern, use the wildcard operator * (asterisk) in your query to match any string. You can use the operator in property names, property values, tag names, and tag values.

If you must search for the asterisk symbol as a value in a query, surround the string in double quotes to avoid the symbol having any special meaning. If the string itself contains double quotes, escape them with a backslash.

Statement typeSyntaxDescription
begins withabc*Begins with “abc”
ends with*abcEnds with “abc”
begins and endsabc*xyzBegins with “abc” and ends with “xyz”

Search for related resources

To find related resources use the relationship operator -> to search for relationships between two sets of resources. To locate resources that are not related, use the inverted relationship operator !->.

Count search results

To count the results of a search, add count(pname) at the end of the search query. This type of aggregation is supported for queries that don’t include the relationship operator.

Double quotes syntax rules

The usage of double quotes around strings is optional in most cases. However, you must enter double quotes if the string contains special characters that might cause ambiguity during parsing.

QueryDescription
tag.Project = StardeckEquivalent to tag.Project = “Stardeck”. Double quotes are not required.
tag.Project = “Stardeck(1)”Double quotes are required because of the brackets. Otherwise the query is invalid.
tag.Description = “This is a description with spaces”Double quotes are required because of the spaces.
tag.Description = “This is a description with spaces and special characters !@#$%^&*()_+[]”Double quotes are required so that each of the special characters is interpreted literally.
tag.Description = “This is a description with spaces and "quotes"”Double quotes are required and the quotes must be escaped with a backslash.