graviti.openapi.search#

Interfaces about the search.

Module Contents#

Functions#

create_search(access_key, url, owner, dataset, *, commit_id, sheet, criteria, offset = None, limit = None)

Execute the OpenAPI POST /v2/datasets/{owner}/{dataset}/commits/{commit_id}/sheets /{sheet}/search?offset={offset}&limit={limit}.

Execute the OpenAPI POST /v2/datasets/{owner}/{dataset}/commits/{commit_id}/sheets /{sheet}/search?offset={offset}&limit={limit}.

Parameters
  • access_key (str) – User’s access key.

  • url (str) – The URL of the graviti website.

  • owner (str) – The owner of the dataset.

  • dataset (str) – Name of the dataset, unique for a user.

  • commit_id (str) – The commit id.

  • sheet (str) – The sheet name.

  • criteria (Dict[str, Any]) – The criteria of the search.

  • offset (Optional[int]) – The offset of the page. The default value of this param in OpenAPIv2 is 0.

  • limit (Optional[int]) – The limit of the page. The default value of this param in OpenAPIv2 is 128.

Returns

The response of OpenAPI.

Return type

Dict[str, Any]

Examples

>>> create_search(
...     "ACCESSKEY-********",
...     "https://gas.graviti.com/gatewayv2/tensorbay-open-api",
...     "czhual",
...     "BDD100K",
...     commit_id = "fde63f357daf46088639e9f57fd81cad",
...     sheet = "train",
...     criteria = {
...         "opt": "or",
...         "value": [
...             {
...                 "opt": "eq",
...                 "key": "filename",
...                 "value": "0000f77c-6257be58.jpg"
...             },
...             {
...                 "opt": "and",
...                 "value": [
...                     {
...                         "opt": "eq",
...                         "key": "attribute.weather",
...                         "value": "clear"
...                     },
...                     {
...                         "opt": "eq",
...                         "key": "attribute.timeofday",
...                         "value": "daytime"
...                     }
...                 ]
...             }
...         ]
...     }
... )
{
    "data": [
        {
            "__record_key": "123750493121329585",
            "filename": "0000f77c-6257be58.jpg",
            "image": {
                "url": "https://content-store-prod-vers",
                "checksum": "dcc197970e607f7576d978972f6fb312911ce005"
            },
            "attribute": {
                "weather": "clear",
                "scene": "city street",
                "timeofday": "daytime"
            }
        },
        ...(total 128 items)
    ],
    "offset": 0,
    "record_size": 128,
    "total_count": 200
}