Search Index Query

Search Index Query
API for efficient query/search over the managed objects (resource model) data.

API for efficient query/search over the managed objects (resource model) data.

It provides means to filter and retrieve projections (subsets) onto the matched resources' properties. Executes the provided SearchIndexQuerySpec instance, i.e., retrieves a snapshot of the resource model data as specified in the query.

Since: vSphere API Release 9.1.0.0

Required privileges: System.View

Request
URI
POST
https://{vcenter-host}/sdk/vim25/{release}/SearchIndex/{moId}/Query
COPY
Path Parameters
string
moId
Required

The unique identifier for the managed object to which the method attaches; the serialized managed object reference for a request has the form moType/moId, in this case SearchIndex/{moId}.

string
release
Required

The vSphere release schema. The current specification covers vSphere 9.1.0.0 APIs.


Request Body
QueryRequestType of type(s) application/json
Required

Show optional properties

{
    "querySpec": {}
}
{
    "querySpec": {
        "_typeName": "string",
        "properties": [
            "string"
        ],
        "resourceType": "string",
        "filters": [
            {
                "_typeName": "string",
                "predicates": [
                    {
                        "_typeName": "string",
                        "propertyPath": "string",
                        "operator": "string",
                        "arrayOperator": "string",
                        "comparableValue": {
                            "_typeName": "string"
                        },
                        "comparableList": [
                            {
                                "_typeName": "string"
                            }
                        ]
                    }
                ]
            }
        ],
        "returnTotalCount": false,
        "limit": 0
    }
}
querySpec
Required

The query that defines the managed objects data to retrieve.

Authentication
This operation uses the following authentication methods.
Responses
200

Result set with data retrieved for the provided query.

Returns SearchIndexResultSet of type(s) application/json
This response body class contains all of the following: DataObject
{
    "_typeName": "string",
    "properties": [
        "string"
    ],
    "items": [
        {
            "_typeName": "string",
            "propertyValues": [
                {
                    "_typeName": "string",
                    "value": {
                        "_typeName": "string"
                    }
                }
            ]
        }
    ],
    "totalCount": 0,
    "marker": "string"
}
array of string
properties
Optional

The names of the resource model properties returned for each resource item in the result set.

The position (index) of each model property in this list corresponds to the position of the model property value in each resource item's values list. In other words, the name of each model property in the SearchIndexResourceItem.propertyValues list is given by the string with the same index (position) in this list.

array of object
items
Optional

The list of result items.

Each item corresponds to a particular resource that matched the conditions in the specified SearchIndexQuerySpec instance and containing the property data retrieved for that resource.

integer As int32 As int32
totalCount
Optional

The total number of resources that matched the query, regardless of the actual number that is returned in SearchIndexResultSet.items.

This value is set only if it has been explicitly requested in the query, i.e. if the SearchIndexQuerySpec.returnTotalCount flag has been set to true. The totalCount can change as new records are added or removed between requests. This means the count is recalculated on each subsequent request to reflect the most up-to-date results. The usecase of this property is for requesting only the items matching certain query without any further properties for the resource model. For example: find the number of all vms that are powered on.

string
marker
Optional

Used for continuation of result paging.

If paging used this one will be filled with the place where the next page should continue from. It should be passed to SearchIndexIterationSpec.marker, so the paging can be continued.


500

InvalidArgument: if SearchIndexQuerySpec is not specified correctly

Returns InvalidArgument of type(s) application/json
This response body class contains all of the following: RuntimeFault
{
    "_typeName": "string",
    "faultCause": {
        "_typeName": "string",
        "faultCause": "MethodFault Object",
        "faultMessage": [
            {
                "_typeName": "string",
                "key": "string",
                "arg": [
                    {
                        "_typeName": "string",
                        "key": "string",
                        "value": {
                            "_typeName": "string"
                        }
                    }
                ],
                "message": "string"
            }
        ]
    },
    "faultMessage": [
        {
            "_typeName": "string",
            "key": "string",
            "arg": [
                {
                    "_typeName": "string",
                    "key": "string",
                    "value": {
                        "_typeName": "string"
                    }
                }
            ],
            "message": "string"
        }
    ],
    "invalidProperty": "string"
}
string
invalidProperty
Optional

Optional name of the invalid property.


Code Samples
COPY
                    curl -X POST -H 'Authorization: <value>' -H 'Content-Type: application/json' -d '{"querySpec":"{}"}' https://{api_host}/sdk/vim25/{release}/SearchIndex/{moId}/Query