NSX-T Data Center REST API
Full text search API
Query Syntax
A query is broken up into terms and operators. A term is case insensitive and can be a single word such as "Hello" or " World " or a phrase surrounded by double quotes such as "Hello World", which would search for the exact phrase.
Field Names
By default, all the fields will be searched for the search term specified. Specific fields to be searched on can be provided via the field name followed by a colon ":" and then the search term.
To search for all the entities where display_name field is "App-VM-1", use
display_name:App-VM-1
Use the dot notation to search on nested fields
tags.scope:prod
Wildcards
Wildcard searches can be run using ? to substitute a single character or * to substitute zero or more characters
*vm* will match all the entities that contains the term "vm" in any of its fields
display_name:App-VM-? will match App-VM-1, App-VM-2, App-VM-A etc..
display_name:App* will match everything where display_name begins with App
Warning: Be aware that using wildcards especially at the beginning of a word i.e. *vm can use a large amount of memory and may perform badly.
Boolean Operators
Search terms can be combined using boolean operators AND, OR and NOT. (Note: Boolean operators must be ALL CAPS).
AND
The AND ( && ) operator matches entities where both terms exist in any of the fields of an entity.
To search for Firewall rule with display_name containing block, use
display_name:*block* AND resource_type:FirewallRule
OR
The OR ( || ) operator links two terms and finds matching entities if either of the terms exists in an entity.
To search for Firewall rule with display_name containing either block or allow, use
display_name:*block* OR display_name:*allow* AND resource_type:FirewallRule
display_name:(*block* OR *allow*) AND resource_type:FirewallRule
NOT
The NOT ( ! ) operator excludes entities that contain the term after NOT.
To search for Firewall rule with display_name does not contain the term block
NOT display_name:*block* AND resource_type:FirewallRule
!display_name:*block* AND resource_type:FirewallRule
Ranges
Ranges can be specified for numeric or string fields and use the following syntax
vni:>50001
vni:>=50001
vni:<90000
vni:<=90000
To combine an upper and lower bound, you would need to join two clauses with AND operator:
vni:(>=50001 AND <90000)
Reserved Characters
If characters which function as operators are to be used in the query (not as operators), then they should be escaped with a leading backslash.
To search for (a+b)=c
\(a\+b\)\=c
.
The reserved characters are: + - = && || > < ! ( ) { } [ ] ^ " ~ * ? : \ /
Failing to escape these reserved characters correctly would lead to syntax errors and prevent the query from running.
Searchable types+
Request:
/api/v1/search/query