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

# Search

> Full-text search across all EU frameworks with the Law4Devs PHP SDK.

## Overview

The search endpoint lets you query across all frameworks simultaneously. Results include articles, recitals, and requirements that match your query. Use `$client->search->query()` to search.

***

## Methods

### `query()`

Search across all frameworks (or a specific one).

```php theme={null}
// Search everything
$results = $client->search->query('incident notification 72 hours');

printf("Found %d results\n", $results->meta->total);
foreach ($results->data as $result) {
    printf("  [%s] %s — %s\n",
        strtoupper($result->frameworkSlug),
        $result->type,
        $result->title ?? $result->matchContext,
    );
}
```

**Parameters**

| Parameter     | Type           | Default  | Description                                               |
| ------------- | -------------- | -------- | --------------------------------------------------------- |
| `$q`          | `string`       | required | Search query                                              |
| `$framework`  | `string\|null` | `null`   | Limit to one framework slug                               |
| `$resultType` | `string\|null` | `null`   | Filter by type: `'article'`, `'recital'`, `'requirement'` |
| `$page`       | `int\|null`    | `null`   | Page number                                               |
| `$perPage`    | `int\|null`    | `null`   | Items per page                                            |

**Returns** `Page<SearchResult>`

***

## Model

### `SearchResult`

| Field             | Type           | Description                                  |
| ----------------- | -------------- | -------------------------------------------- |
| `type`            | `string`       | `'article'`, `'recital'`, or `'requirement'` |
| `frameworkSlug`   | `string`       | Framework the result belongs to              |
| `frameworkName`   | `string`       | Human-readable framework name                |
| `articleNumber`   | `int\|null`    | For article results                          |
| `recitalNumber`   | `int\|null`    | For recital results                          |
| `paragraphRef`    | `string\|null` | Specific paragraph reference                 |
| `title`           | `string\|null` | Result heading, if any                       |
| `requirementType` | `string\|null` | For requirement results                      |
| `matchContext`    | `string`       | Snippet showing the match in context         |
| `url`             | `string`       | Direct API URL to the full resource          |

***

## Examples

### Search across specific frameworks

```php theme={null}
$results = $client->search->query(
    q:         'breach notification',
    framework: 'gdpr',
);

foreach ($results->data as $r) {
    echo $r->frameworkSlug . ' — ' . ($r->title ?? $r->matchContext) . "\n";
}
```

### Filter by result type

```php theme={null}
$results = $client->search->query(
    q:          'encryption at rest',
    resultType: 'requirement',
);

foreach ($results->data as $r) {
    echo '- ' . $r->matchContext . "\n";
}
```

### Cross-framework search

```php theme={null}
$frameworks = ['nis2', 'dora', 'cra'];
foreach ($frameworks as $fw) {
    $results = $client->search->query('incident notification', framework: $fw);
    printf("%-6s %d results\n", $fw, $results->meta->total);
}
```

<Tip>
  Use the `$framework` parameter to narrow results when you know which regulation you're working with. Cross-framework search (without a filter) is great for discovering related obligations across different laws.
</Tip>
