Search > Search 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

*vmwill 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:

Method:
GET
URI Path(s):
/api/v1/search/query
Request Headers:
n/a
Query Parameters:
SearchQueryRequest+
Request Body:
n/a

Example Request:

GET https://<nsx-mgr>/api/v1/search/query?query=resource_type:group&page_size=2 GET https://<nsx-mgr>/policy/api/v1/search/query?query=resource_type:group&page_size=2 GET https://<nsx-mgr>/global-manager/api/v1/search/query?query=resource_type:group&page_size=2

Successful Response:

Response Code:
200 OK
Response Headers:
Content-type: application/json
Response Body:
SearchResponse+

Example Response:

{ "results": [ { "_last_modified_user": "admin", "_revision": 4, "_system_owned": false, "resource_type": "Group", "description": "Prod Env Group", "_protection": "NOT_PROTECTED", "_last_modified_time": 1561700732921, "display_name": "ProdEnvGroup", "_create_user": "admin", "tags": [ { "scope": "Prod", "tag": "Group" } ], "_create_time": 1561614698915, "path": "/infra/domains/default/groups/4fc8c310-989f-11e9-baf3-930b233a84c6", "marked_for_delete": false, "parent_path": "/infra/domains/default", "id": "4fc8c310-989f-11e9-baf3-930b233a84c6", "relative_path": "4fc8c310-989f-11e9-baf3-930b233a84c6", "status": { "consolidated_status_per_enforcement_point": [ { "consolidated_status": { "consolidated_status": "SUCCESS" }, "enforcement_point_id": "default" } ], "consolidated_status": { "consolidated_status": "SUCCESS" }, "intent_path": "/infra/domains/default/groups/4fc8c310-989f-11e9-baf3-930b233a84c6" } }, { "_last_modified_user": "admin", "_revision": 0, "_system_owned": false, "resource_type": "Group", "description": "DevOps Environment Group", "_protection": "NOT_PROTECTED", "_last_modified_time": 1561707088516, "display_name": "DevOpsEnvGroup", "_create_user": "admin", "tags": [ { "scope": "DevOps", "tag": "Group" } ], "_create_time": 1561707088516, "path": "/infra/domains/default/groups/DevOpsEnvGroup", "marked_for_delete": false, "parent_path": "/infra/domains/default", "id": "DevOpsEnvGroup", "relative_path": "DevOpsEnvGroup", "status": { "consolidated_status_per_enforcement_point": [ { "consolidated_status": { "consolidated_status": "SUCCESS" }, "enforcement_point_id": "default" } ], "consolidated_status": { "consolidated_status": "SUCCESS" }, "intent_path": "/infra/domains/default/groups/DevOpsEnvGroup" } } ], "result_count": 3, "cursor": "2" }

Required Permissions:

read

Feature:

search

Additional Errors: