> ## Documentation Index
> Fetch the complete documentation index at: https://docs.videodb.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Query

> Run structured filters over one queryable index.

## Endpoints

```http theme={null}
POST /video/{video_id}/query/
POST /collection/{collection_id}/query/
```

Use `query()` when you know the exact index and filter fields.

## Request body

| Field           |               Type |    Required | Description                                                           |
| --------------- | -----------------: | ----------: | --------------------------------------------------------------------- |
| `index_name`    |             string | conditional | Index name to query. Required unless `index_id` is provided.          |
| `index_id`      |             string | conditional | Index ID to query. Required unless `index_name` is provided.          |
| `filter`        |        list/object |          no | Explicit filter spec. A top-level list is an implicit AND.            |
| `limit`         |            integer |          no | Maximum returned rows/moments. Defaults to server direct-query limit. |
| `sort`          | list/string/object |          no | Sort field and direction.                                             |
| `return_fields` |   string/list/dict |          no | Select indexes to hydrate under `shot.metadata["indexes"]`.           |

Do not pass `index_names` or `index_ids` to `query()`.

## Example

```python theme={null}
results = collection.query(
    index_name="objects",
    filter=[
        {"field": "label", "op": "contains", "value": "cell phone"},
    ],
    limit=100,
    sort=[("max_score", "desc")],
    return_fields=["objects"],
)
```

## Response

Returns a `SearchResult` containing `Shot` objects.
