> For the complete documentation index, see [llms.txt](https://api.clearinghouse.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://api.clearinghouse.net/api-reference-v2p1/endpoints/case-text-search.md).

# Case Text Search

### Get cases by full-text search (string).

<mark style="color:blue;">`GET`</mark> `https://clearinghouse.net/api/v2p1/cases/?text=search_string`

**Headers**

| Name                                            | Type   | Description                                                                                                                    |
| ----------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------ |
| Authorization<mark style="color:red;">\*</mark> | String | <p>Authorization</p><p><code>Token XXXXXXXXXXX</code></p><p>where</p><p><code>XXXXXXXXXXX</code></p><p>is the token string</p> |

{% tabs %}
{% tab title="200 Cases successfully retrieved" %}

{% endtab %}

{% tab title="400: Bad Request No results, key not found, or invalid parameter" %}

```
\\ No results
\\ Example query endpoint: /api/v2p1/cases/?text=zzznomatch
["No results for {'text': 'zzznomatch'}"]

\\ Key not found
\\ Example query endpoint: /api/v2p1/cases?test_key=1
["API Error: Key: test_key, Value: 1 not found."]
```

{% endtab %}

{% tab title="401 Permission denied" %}

```javascript
{
    "detail":"Authentication credentials were not provided."
}
```

{% endtab %}
{% endtabs %}

Returns all cases that have at least one document matching the search query. Note: this search uses the same index as the [Document text search](/api-reference-v2p1/endpoints/documents.md#text-search). Searching cases by `text` returns cases that have at least one document matching the query. Search is powered by PostgreSQL full-text search and runs across the following fields, in descending order of relevance weight:

| Field          | Weight      |
| -------------- | ----------- |
| Case name      | A (highest) |
| Document title | B           |
| Case summary   | C           |
| Document text  | D (lowest)  |

Queries are matched using PostgreSQL's `SearchQuery`, which supports natural language stemming (e.g. "running" matches "run"). Multi-word queries are treated as AND by default — all terms must appear somewhere across the searched fields.

**Example**

{% tabs %}
{% tab title="URL" %}

```
https://clearinghouse.net/api/v2p1/cases?text=solitary+confinement
```

{% endtab %}

{% tab title="python" %}

```python
import requests

url = "https://clearinghouse.net/api/v2p1/cases?text=solitary+confinement"
headers = { 'Authorization': 'Token XXXXXXXXXX',
'User-Agent': 'Chrome v22.2 Linux Ubuntu'
}
response = requests.request("GET", url, headers=headers, data={})

print(response.text)
```

{% endtab %}
{% endtabs %}
