graviti.openapi.search#

Interfaces about the search.

Module Contents#

Functions#

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

Execute the OpenAPI POST /v2/datasets/{owner}/{dataset}/commits/{commit_id}/sheets /{sheet}/search.

Execute the OpenAPI POST /v2/datasets/{owner}/{dataset}/commits/{commit_id}/sheets /{sheet}/search.

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.

  • search_id (Optional[str]) – The search id of this 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 to get all search results.

Returns

The response of OpenAPI.

Return type

Dict[str, Any]

Examples

>>> create_search(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "graviti-example",
...     "BDD100K",
...     commit_id = "fde63f357daf46088639e9f57fd81cad",
...     sheet = "train",
...     criteria = {
...         "where": {
...            "$or": [
...                {
...                    "$eq": ["$.filename", "0000f77c-6257be58.jpg"],
...                },
...                {
...                    "$and": [
...                        {
...                            "$eq": ["$.attribute.weather", "clear"]
...                        },
...                        {
...                            "$eq": ["$.attribute.timeofday", "daytime"]
...                        }
...                    ]
...                }
...            ]
...        },
...        "offset": 0,
...        "limit": 128
...    }
... )
{
    "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)
    ],
    "search_id": "5c7de503c88446e8b37a258f71783d7d"
}

Use search_id to avoid creating new search.

>>> create_search(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "graviti-example",
...     "BDD100K",
...     commit_id = "fde63f357daf46088639e9f57fd81cad",
...     sheet = "train",
...     criteria = {"where": {"$eq": ["$.filename", "0000f77c-6257be58.jpg"]}}
...     search_id = "5c7de503c88446e8b37a258f71783d7d"
... )
{
    "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)
    ],
    "search_id": "5c7de503c88446e8b37a258f71783d7d"
}