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

# Phrase Filters: Niche Company Finder

***

## What this doc covers

1. What Phrase filters are and how they work
2. Using 'Phrase Filters' to find specific results, in this case filtering by a foreign company suffix

In this simple example, we'll demonstrate a company discovery search that helps find relevant companies incorporated in the Germany (and a few nearby countries) via Phrase Filters. This example will use the fact that companies incorporated in these locations [have a suffix of GmbH](https://en.wikipedia.org/wiki/GmbH), which is a term in the region similar to the US 'incorporated'.

## How Phrase Filters work

Exa's search combines semantic relevance with precise filtering: a semantic query first retrieves contextually relevant documents, then a phrase filter refines these results by checking for specific text in the content. This two-stage approach delivers highly targeted outputs by leveraging both semantic understanding and exact text matching.

<img src="https://mintcdn.com/exa-52/tmzyKnsgpKLGddKC/images/1864e57-Screenshot_2024-07-16_at_05.41.13.png?fit=max&auto=format&n=tmzyKnsgpKLGddKC&q=85&s=758bc3c59268a1678e9022748af47aa8" alt="" width="550" height="837" data-path="images/1864e57-Screenshot_2024-07-16_at_05.41.13.png" />

## Running a query with phrase filter

Using Phrase Filters is super simple. As usual, install the `exa_py` library with `pip install exa_py`. Then instantiate the library:

```Python Python theme={null}
# Import the Exa class. The API key is read from the EXA_API_KEY environment variable.
from exa_py import Exa

exa = Exa()
```

Make a query, in this example searching for the most innovative climate tech companies. To use Phrase Filters, specify a string corresponding to the `includeText` input parameter

```Python Python theme={null}
result = exa.search(
  "Here is an innovative climate technology company",
  type="auto",
  num_results=10,
  contents={"highlights": True},
	include_text=["GmbH"]
)

print(result)
```

Which outputs:

```
{
  "results": [
    {
      "title": "Sorption Technologies |",
      "id": "https://sorption-technologies.com/",
      "url": "https://sorption-technologies.com/",
      "publishedDate": "2024-02-10",
      "author": null,
      "highlights": [
        "Sorption Technologies GmbH develops materials for energy-efficient carbon capture and storage."
      ],
      "highlightScores": [0.86]
    },
    {
      "title": "intelligent fluids | LinkedIn",
      "id": "https://www.linkedin.com/company/intelligentfluids",
      "url": "https://www.linkedin.com/company/intelligentfluids",
      "publishedDate": "2023-06-08",
      "author": null,
      "highlights": [
        "intelligent fluids GmbH develops sustainable industrial cleaning fluids for reducing waste and emissions."
      ],
      "highlightScores": [0.79]
    },
    {
      "title": "Green City Solutions",
      "id": "https://www.greentalents.de/green-city-solutions.php",
      "url": "https://www.greentalents.de/green-city-solutions.php",
      "publishedDate": "2022-04-12",
      "author": null,
      "highlights": [
        "Green City Solutions GmbH combines moss with Internet of Things technology to clean and cool urban air."
      ],
      "highlightScores": [0.74]
    }
  ],
  "requestId": "a02fd414d9ca16454089e8720cd6ed2b"
}
```

Nice! On inspection, these results include companies located in Hamburg, Munich and other close by European locations. This example can be extended to any key phrase - have a play with filtering via [other company suffixes - ](https://en.wikipedia.org/wiki/List%5Fof%5Flegal%5Fentity%5Ftypes%5Fby%5Fcountry) and see what interesting results you get back!
