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

# Search

The `search` method performs a text-based search across records in the collection.

## Configuration Example

```yaml theme={null}
# spec.yml
name: Collection Name
methods:
  search:
    parametersSchema:
      type: object
      properties:
        searchFields:
          type: array
          items:
            type: string
            enum: ['name', 'email', 'phone']
          default: ['name', 'email']
          description: Fields to search in
```

## Implementation Examples

```javascript theme={null}
module.exports = async ({ query, cursor, credentials, parameters }) => {
  const response = await makeApiRequest({
    method: 'GET',
    path: '/api/contacts/search',
    query: {
      q: query,
      limit: 50,
      offset: cursor || 0,
    },
    credentials,
  })

  return {
    records: response.data,
    cursor: response.hasMore ? String((cursor || 0) + 50) : undefined,
  }
}
```

## Input

| Property      | Type   | Description                             |
| ------------- | ------ | --------------------------------------- |
| `query`       | string | The search query string                 |
| `cursor`      | string | Pagination cursor from previous request |
| `credentials` | object | Authentication credentials              |
| `parameters`  | object | Method-specific parameters              |

## Return Value

| Property  | Type   | Description                     |
| --------- | ------ | ------------------------------- |
| `records` | array  | Array of matching records       |
| `cursor`  | string | Cursor for next page (optional) |
