---
title: "Search in collection"
method: POST
path: "/_fabric/{fabric}/_api/search"
tags: ["Search"]
---

# Search in collection

`POST /_fabric/{fabric}/_api/search`

## Request

- The document declares no server URL.
- Auth: one of:
  - API key in header `Authorization`
  - HTTP bearer
- TypeScript: <https://skmtc.dev/macrometa/apis/macrometa-api-reference/docs/_fabric/:fabric/_api/search/post.ts> (a function with typed inputs; its response is checked against the schema)

Search a collection for string matches.

The specified search query is ran for the collection. If there are too many results, the cursor *id* can be used to obtain the remaining results.

 **Note**: This API is applicable for collections with search capability enabled. For user created views, use C8QL query to run search operation.

## Path parameters

- `fabric` string, string, required

## Request body

- ApiSearchViewSearch
  - `collection` string, required: Collection in which to search.
  - `search` string, required: C8QL search query, specifying search criteria for the documents in the collection.
  - `bindVars` object: Bind variables for the search query.
  - `ttl` integer: How long search results should be preserved by the server (in seconds).

## Response `200`

Successfully fetched search results.

- ApiSearchGetViewHttpExamplesRc200
  - `code` integer: HTTP response code.
  - `error` boolean: Flag if there is an error in response. *False* for this response.
  - `hasMore` boolean: *True* if more results available for the cursor on the server
  - `count` number: Number of matching documents.
  - `cached` boolean: *True* if indicating whether the query result was served from the query cache or not
  - `result` unknown[]: The array of matching documents.
    - unknown

## Other responses

- `400`: Failed due to missing or malformed data. Verify that all parameters are complete.
- `403`: Failed to validate because you do not have access to the server.
- `404`: Failed to find specified collection.

---

[API](https://skmtc.dev/macrometa/apis/macrometa-api-reference.md) - [All operations](https://skmtc.dev/macrometa/apis/macrometa-api-reference/llms.txt) - [OpenAPI document](https://skmtc.dev/macrometa/apis/macrometa-api-reference/revisions/2006b6d7f31d?raw)
