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.
What this doc covers
- What Phrase filters are and how they work
- 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, 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.
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:
# Now, import the Exa class and pass your API key to it.
from exa_py import Exa
my_exa_api_key = "YOUR_API_KEY_HERE"
exa = Exa(api_key=my_exa_api_key)
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
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 - and see what interesting results you get back!