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

# Business Search query examples

> Tested Business Search examples: companies by office location or description phrase, people by past employer, and a multi-step company-then-people search.

This page shows tested Business Search requests for prospecting and hiring questions:

* [Find companies by office location instead of headquarters](#how-to-find-companies-by-office-location-instead-of-headquarters), with `in` on `offices_country_codes`
* [Match a phrase in company descriptions or specialties](#how-to-match-a-phrase-in-company-descriptions-or-specialties), with `or` and `mode: "all"`
* [Find people by a past employer](#how-to-find-people-by-a-past-employer), with `past_company_names` and `not`
* [Run a multi-step search](#how-to-run-a-multi-step-search), a company search followed by a people search

Every request reads the API key from the `BRIGHTDATA_API_KEY` environment variable, as set in [Step 1 of the quickstart](https://docs.brightdata.com/products/business-search/quickstart.md#step-1-get-and-set-your-api-key). Your records and `matched` counts will differ from the sample responses, because results move between runs.

## How to find companies by office location instead of headquarters

To find software companies with an office in Germany, wherever they are headquartered, filter on `offices_country_codes` rather than `headquarters_country_code`. The field is an array of country codes and takes `in`, so one condition matches every company with an office in any listed country. Instant and Smart take the same intent as a sentence.

> [tab] Ludicrous
>
> A Ludicrous request combines `software` in the industry with `DE` in the office country codes. The `text` condition sets `mode: "all"`: in testing, the default mode reached only a small share of the matching companies, and a different share on each run:
>
> **Sample request**
>
> ```bash cURL highlight={9} theme={null}
> curl --request POST "https://api.brightdata.com/search/company" \
>   --header "Authorization: Bearer $BRIGHTDATA_API_KEY" \
>   --header "Content-Type: application/json" \
>   --data '{
>     "mode": "ludicrous",
>     "query": {
>       "and": [
>         { "text": { "industry": { "value": "software", "mode": "all" } } },
>         { "in": { "offices_country_codes": ["DE"] } }
>       ]
>     },
>     "limit": 3,
>     "view": { "fields": ["name", "industry", "headquarters_location", "offices_country_codes", "website"] }
>   }'
> ```
>
> ```python Python highlight={15} theme={null}
> import os
> import requests
>
> response = requests.post(
>     "https://api.brightdata.com/search/company",
>     headers={
>         "Authorization": f"Bearer {os.environ['BRIGHTDATA_API_KEY']}",
>         "Content-Type": "application/json",
>     },
>     json={
>       "mode": "ludicrous",
>       "query": {
>         "and": [
>           { "text": { "industry": { "value": "software", "mode": "all" } } },
>           { "in": { "offices_country_codes": ["DE"] } }
>         ]
>       },
>       "limit": 3,
>       "view": { "fields": ["name", "industry", "headquarters_location", "offices_country_codes", "website"] }
>     },
> )
> print(response.text)
> ```
>
> ```javascript Node.js highlight={12} theme={null}
> const response = await fetch("https://api.brightdata.com/search/company", {
>   method: "POST",
>   headers: {
>     "Authorization": `Bearer ${process.env.BRIGHTDATA_API_KEY}`,
>     "Content-Type": "application/json",
>   },
>   body: JSON.stringify({
>     "mode": "ludicrous",
>     "query": {
>       "and": [
>         { "text": { "industry": { "value": "software", "mode": "all" } } },
>         { "in": { "offices_country_codes": ["DE"] } }
>       ]
>     },
>     "limit": 3,
>     "view": { "fields": ["name", "industry", "headquarters_location", "offices_country_codes", "website"] }
>   }),
> });
> console.log(await response.text());
> ```
>
> **Sample response**
>
> The first of the three returned records:
>
> ```json theme={null}
> {
>   "req_id": "rb8545422f0a1478690c2b51666b48de2",
>   "source": "linkedin_company",
>   "meta": {
>     "coverage_percent": 100,
>     "matched": 23123,
>     "offset": 0,
>     "limit": 3
>   },
>   "documents": [
>     {
>       "bright_id": "497e671df1de83a45eec09ac98062e8149b2f4cc8ca4e9cfbf89dc86a45404dd",
>       "data": {
>         "name": "Google",
>         "industry": "Software Development",
>         "headquarters_location": "Mountain View, CA",
>         "offices_country_codes": [
>           "PL",
>           "CA",
>           "CL",
>           "SE",
>           "AU",
>           "US",
>           "SG",
>           "DE",
>           "ES",
>           "FR",
>           "MX",
>           "CH",
>           "IT",
>           "IN",
>           "NL",
>           "CO",
>           "BR",
>           "HK",
>           "AR",
>           "PH",
>           "IL",
>           "IE",
>           "GB"
>         ],
>         "website": "https://goo.gle/3DLEokh"
>       }
>     }
>   ]
> }
> ```

> [tab] Instant
>
> An Instant request sends the intent as one sentence:
>
> **Sample request**
>
> ```bash cURL highlight={6} theme={null}
> curl --request POST "https://api.brightdata.com/search/company" \
>   --header "Authorization: Bearer $BRIGHTDATA_API_KEY" \
>   --header "Content-Type: application/json" \
>   --data '{
>     "mode": "instant",
>     "query": "Software companies with an office in Germany",
>     "limit": 3,
>     "view": { "fields": ["name", "industry", "headquarters_location", "offices_country_codes", "website"] }
>   }'
> ```
>
> ```python Python highlight={12} theme={null}
> import os
> import requests
>
> response = requests.post(
>     "https://api.brightdata.com/search/company",
>     headers={
>         "Authorization": f"Bearer {os.environ['BRIGHTDATA_API_KEY']}",
>         "Content-Type": "application/json",
>     },
>     json={
>       "mode": "instant",
>       "query": "Software companies with an office in Germany",
>       "limit": 3,
>       "view": { "fields": ["name", "industry", "headquarters_location", "offices_country_codes", "website"] }
>     },
> )
> print(response.text)
> ```
>
> ```javascript Node.js highlight={9} theme={null}
> const response = await fetch("https://api.brightdata.com/search/company", {
>   method: "POST",
>   headers: {
>     "Authorization": `Bearer ${process.env.BRIGHTDATA_API_KEY}`,
>     "Content-Type": "application/json",
>   },
>   body: JSON.stringify({
>     "mode": "instant",
>     "query": "Software companies with an office in Germany",
>     "limit": 3,
>     "view": { "fields": ["name", "industry", "headquarters_location", "offices_country_codes", "website"] }
>   }),
> });
> console.log(await response.text());
> ```
>
> **Sample response**
>
> The first of the three returned records:
>
> ```json theme={null}
> {
>   "req_id": "rd24753db731c4a6b806c638fad544cc5",
>   "source": "linkedin_company",
>   "meta": {
>     "coverage_percent": 100,
>     "matched": 749,
>     "offset": 0,
>     "limit": 3
>   },
>   "documents": [
>     {
>       "bright_id": "12d1ece1155dded506f3473ba5574f2e0e6c067f420dcaf0bda9e9cec58488dd",
>       "data": {
>         "name": "Maxon",
>         "industry": "Software Development",
>         "headquarters_location": "Bad Homburg",
>         "offices_country_codes": [
>           "DE",
>           "US",
>           "CA",
>           "JP"
>         ],
>         "website": "https://www.maxon.net/"
>       }
>     }
>   ]
> }
> ```

> [tab] Smart
>
> A Smart request sends the same sentence and ranks the candidates by how well each record answers it:
>
> **Sample request**
>
> ```bash cURL highlight={6} theme={null}
> curl --request POST "https://api.brightdata.com/search/company" \
>   --header "Authorization: Bearer $BRIGHTDATA_API_KEY" \
>   --header "Content-Type: application/json" \
>   --data '{
>     "mode": "smart",
>     "query": "Software companies with an office in Germany",
>     "limit": 3,
>     "view": { "fields": ["name", "industry", "headquarters_location", "offices_country_codes", "website"] }
>   }'
> ```
>
> ```python Python highlight={12} theme={null}
> import os
> import requests
>
> response = requests.post(
>     "https://api.brightdata.com/search/company",
>     headers={
>         "Authorization": f"Bearer {os.environ['BRIGHTDATA_API_KEY']}",
>         "Content-Type": "application/json",
>     },
>     json={
>       "mode": "smart",
>       "query": "Software companies with an office in Germany",
>       "limit": 3,
>       "view": { "fields": ["name", "industry", "headquarters_location", "offices_country_codes", "website"] }
>     },
> )
> print(response.text)
> ```
>
> ```javascript Node.js highlight={9} theme={null}
> const response = await fetch("https://api.brightdata.com/search/company", {
>   method: "POST",
>   headers: {
>     "Authorization": `Bearer ${process.env.BRIGHTDATA_API_KEY}`,
>     "Content-Type": "application/json",
>   },
>   body: JSON.stringify({
>     "mode": "smart",
>     "query": "Software companies with an office in Germany",
>     "limit": 3,
>     "view": { "fields": ["name", "industry", "headquarters_location", "offices_country_codes", "website"] }
>   }),
> });
> console.log(await response.text());
> ```
>
> **Sample response**
>
> The first of the three returned records:
>
> ```json theme={null}
> {
>   "req_id": "raf8ab94a0ef649cd8d0eb2a58c800310",
>   "source": "linkedin_company",
>   "meta": {
>     "coverage_percent": 100,
>     "matched": 746,
>     "offset": 0,
>     "limit": 3
>   },
>   "documents": [
>     {
>       "bright_id": "12d1ece1155dded506f3473ba5574f2e0e6c067f420dcaf0bda9e9cec58488dd",
>       "data": {
>         "name": "Maxon",
>         "industry": "Software Development",
>         "headquarters_location": "Bad Homburg",
>         "offices_country_codes": [
>           "DE",
>           "US",
>           "CA",
>           "JP"
>         ],
>         "website": "https://www.maxon.net/"
>       }
>     }
>   ]
> }
> ```

## How to match a phrase in company descriptions or specialties

To find fraud-detection software providers with an office in the United Kingdom, match the words in the text a company writes about itself. `fraud detection software` can appear in `about` or in `specialties`, so the structured query checks both with `or`, and `mode: "all"` requires all three words in the same field. This is a word match, not proof that the company sells fraud detection: a company can describe fraud detection work without offering it as a product.

> [tab] Ludicrous
>
> A Ludicrous request accepts either field and requires a GB office:
>
> **Sample request**
>
> ```bash cURL highlight={10,11} theme={null}
> curl --request POST "https://api.brightdata.com/search/company" \
>   --header "Authorization: Bearer $BRIGHTDATA_API_KEY" \
>   --header "Content-Type: application/json" \
>   --data '{
>     "mode": "ludicrous",
>     "query": {
>       "and": [
>         {
>           "or": [
>             { "text": { "about": { "value": "fraud detection software", "mode": "all" } } },
>             { "text": { "specialties": { "value": "fraud detection software", "mode": "all" } } }
>           ]
>         },
>         { "in": { "offices_country_codes": ["GB"] } }
>       ]
>     },
>     "limit": 3,
>     "view": { "fields": ["name", "industry", "specialties", "offices_country_codes", "website"] }
>   }'
> ```
>
> ```python Python highlight={16,17} theme={null}
> import os
> import requests
>
> response = requests.post(
>     "https://api.brightdata.com/search/company",
>     headers={
>         "Authorization": f"Bearer {os.environ['BRIGHTDATA_API_KEY']}",
>         "Content-Type": "application/json",
>     },
>     json={
>       "mode": "ludicrous",
>       "query": {
>         "and": [
>           {
>             "or": [
>               { "text": { "about": { "value": "fraud detection software", "mode": "all" } } },
>               { "text": { "specialties": { "value": "fraud detection software", "mode": "all" } } }
>             ]
>           },
>           { "in": { "offices_country_codes": ["GB"] } }
>         ]
>       },
>       "limit": 3,
>       "view": { "fields": ["name", "industry", "specialties", "offices_country_codes", "website"] }
>     },
> )
> print(response.text)
> ```
>
> ```javascript Node.js highlight={13,14} theme={null}
> const response = await fetch("https://api.brightdata.com/search/company", {
>   method: "POST",
>   headers: {
>     "Authorization": `Bearer ${process.env.BRIGHTDATA_API_KEY}`,
>     "Content-Type": "application/json",
>   },
>   body: JSON.stringify({
>     "mode": "ludicrous",
>     "query": {
>       "and": [
>         {
>           "or": [
>             { "text": { "about": { "value": "fraud detection software", "mode": "all" } } },
>             { "text": { "specialties": { "value": "fraud detection software", "mode": "all" } } }
>           ]
>         },
>         { "in": { "offices_country_codes": ["GB"] } }
>       ]
>     },
>     "limit": 3,
>     "view": { "fields": ["name", "industry", "specialties", "offices_country_codes", "website"] }
>   }),
> });
> console.log(await response.text());
> ```
>
> **Sample response**
>
> The first of the three returned records:
>
> ```json theme={null}
> {
>   "req_id": "r9a82f304d62748ddabd98aa954291bcd",
>   "source": "linkedin_company",
>   "meta": {
>     "coverage_percent": 100,
>     "matched": 78,
>     "offset": 0,
>     "limit": 3
>   },
>   "documents": [
>     {
>       "bright_id": "b8b445ba5ddcf7dab8342ce3e26609e07f5d864b5dfcef813e7ce2d78bc5f1a5",
>       "data": {
>         "name": "FICO",
>         "industry": "Software Development",
>         "specialties": "Predictive Analytics, Decision Management Tools and Applications, Scores, Consultancy, B2B Enterprise Software, Enterprise Software, Decision Technology, Enterprise Fraud, Cyber security, Fraud Detection, Loan origination software, Applied Intelligence, and AI",
>         "offices_country_codes": [
>           "GB",
>           "IN",
>           "SG",
>           "US"
>         ],
>         "website": "https://www.fico.com/"
>       }
>     }
>   ]
> }
> ```

> [tab] Smart
>
> A Smart request sends the intent as one sentence and ranks the candidates by how well each record answers it:
>
> **Sample request**
>
> ```bash cURL highlight={6} theme={null}
> curl --request POST "https://api.brightdata.com/search/company" \
>   --header "Authorization: Bearer $BRIGHTDATA_API_KEY" \
>   --header "Content-Type: application/json" \
>   --data '{
>     "mode": "smart",
>     "query": "Fraud-detection software providers with an office in the United Kingdom",
>     "limit": 3,
>     "view": { "fields": ["name", "industry", "specialties", "offices_country_codes", "website"] }
>   }'
> ```
>
> ```python Python highlight={12} theme={null}
> import os
> import requests
>
> response = requests.post(
>     "https://api.brightdata.com/search/company",
>     headers={
>         "Authorization": f"Bearer {os.environ['BRIGHTDATA_API_KEY']}",
>         "Content-Type": "application/json",
>     },
>     json={
>       "mode": "smart",
>       "query": "Fraud-detection software providers with an office in the United Kingdom",
>       "limit": 3,
>       "view": { "fields": ["name", "industry", "specialties", "offices_country_codes", "website"] }
>     },
> )
> print(response.text)
> ```
>
> ```javascript Node.js highlight={9} theme={null}
> const response = await fetch("https://api.brightdata.com/search/company", {
>   method: "POST",
>   headers: {
>     "Authorization": `Bearer ${process.env.BRIGHTDATA_API_KEY}`,
>     "Content-Type": "application/json",
>   },
>   body: JSON.stringify({
>     "mode": "smart",
>     "query": "Fraud-detection software providers with an office in the United Kingdom",
>     "limit": 3,
>     "view": { "fields": ["name", "industry", "specialties", "offices_country_codes", "website"] }
>   }),
> });
> console.log(await response.text());
> ```
>
> **Sample response**
>
> The first of the three returned records:
>
> ```json theme={null}
> {
>   "req_id": "rb4c207d88e7e43a7a0dce6da7a06292a",
>   "source": "linkedin_company",
>   "meta": {
>     "coverage_percent": 100,
>     "matched": 828,
>     "offset": 0,
>     "limit": 3
>   },
>   "documents": [
>     {
>       "bright_id": "ea4950408cd68b5abd76383b8a7c8a23c0600616559ad51253b897164bda60f3",
>       "data": {
>         "name": "Resistant AI - Fraud Detection",
>         "industry": "Financial Services",
>         "specialties": "Document Verification, Anti Fraud Software, Spot Fake Bank Statements, ID Verification, Fake Document Detection, Document Fraud Detection, Fraud Prevention, Machine Learning, Artificial Intelligence, Financial Fraud, Document Forgery, KYC, KYB, Onboarding, Loan Fraud, AI Detector, Tenant Screening, Loan Underwriting, Employment Verification, Fraud Detection in Insurance Claims, AML, and Transaction Monitoring",
>         "offices_country_codes": [
>           "CZ",
>           "GB",
>           "US"
>         ],
>         "website": "https://resistant.ai/"
>       }
>     }
>   ]
> }
> ```

## How to find people by a past employer

To find US engineering managers who used to work at Microsoft and have since moved on, combine a `text` condition on `past_company_names` with a `not` condition on `current_company_name`. Send this one as a structured query: in testing, the sentence form found former Microsoft employees but did not exclude people who still work there. `past_company_names` lists employers without dates, so the result shows that the person worked at Microsoft, not when.

Both employer conditions set `mode: "all"`, as the office location recipe does. The `not` condition excludes profiles whose current employer is still Microsoft:

**Sample request**

```bash cURL highlight={9,10} theme={null}
curl --request POST "https://api.brightdata.com/search/people" \
  --header "Authorization: Bearer $BRIGHTDATA_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "mode": "ludicrous",
    "query": {
      "and": [
        { "text": { "current_title": { "value": "engineering manager", "mode": "all" } } },
        { "text": { "past_company_names": { "value": "Microsoft", "mode": "all" } } },
        { "not": { "text": { "current_company_name": { "value": "Microsoft", "mode": "all" } } } },
        { "equals": { "country_code": "US" } }
      ]
    },
    "limit": 3,
    "view": { "fields": ["current_title", "current_company_name", "past_company_names", "country_code"] }
  }'
```

```python Python highlight={15,16} theme={null}
import os
import requests

response = requests.post(
    "https://api.brightdata.com/search/people",
    headers={
        "Authorization": f"Bearer {os.environ['BRIGHTDATA_API_KEY']}",
        "Content-Type": "application/json",
    },
    json={
      "mode": "ludicrous",
      "query": {
        "and": [
          { "text": { "current_title": { "value": "engineering manager", "mode": "all" } } },
          { "text": { "past_company_names": { "value": "Microsoft", "mode": "all" } } },
          { "not": { "text": { "current_company_name": { "value": "Microsoft", "mode": "all" } } } },
          { "equals": { "country_code": "US" } }
        ]
      },
      "limit": 3,
      "view": { "fields": ["current_title", "current_company_name", "past_company_names", "country_code"] }
    },
)
print(response.text)
```

```javascript Node.js highlight={12,13} theme={null}
const response = await fetch("https://api.brightdata.com/search/people", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.BRIGHTDATA_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "mode": "ludicrous",
    "query": {
      "and": [
        { "text": { "current_title": { "value": "engineering manager", "mode": "all" } } },
        { "text": { "past_company_names": { "value": "Microsoft", "mode": "all" } } },
        { "not": { "text": { "current_company_name": { "value": "Microsoft", "mode": "all" } } } },
        { "equals": { "country_code": "US" } }
      ]
    },
    "limit": 3,
    "view": { "fields": ["current_title", "current_company_name", "past_company_names", "country_code"] }
  }),
});
console.log(await response.text());
```

**Sample response**

The first of the three returned records:

```json theme={null}
{
  "req_id": "r8aa70e91316e44e69ffd193c74070a8c",
  "source": "linkedin_people",
  "meta": {
    "coverage_percent": 100,
    "matched": 887,
    "offset": 0,
    "limit": 3
  },
  "documents": [
    {
      "bright_id": "2c592bb9eb4910423f189ed3e6212195ffc987386b5d047ce3184ecdc79a0670",
      "data": {
        "current_title": "Engineering Manager",
        "current_company_name": "Google",
        "past_company_names": "Microsoft; Microsoft Corporation",
        "country_code": "US"
      }
    }
  ]
}
```

## How to run a multi-step search

A question that mixes company and people conditions needs more than one Business Search request. A people search filters only on the [people searchable fields](https://docs.brightdata.com/products/business-search/people-search.md#searchable-fields), such as `current_title` and `current_company_name`. A company search filters on the [company searchable fields](https://docs.brightdata.com/products/business-search/company-search.md#searchable-fields), such as funding and headquarters. A people record can return `current_company_funding_raised` in its view, but a people search cannot filter on it.

Run the search in three steps:

1. Run a company search for the company conditions and collect the company names.
2. Run a people search for the people conditions, limited to those company names.
3. Keep only the profiles whose current employer is one of the companies from step 1.

The example below finds the CEOs of technology companies headquartered in San Francisco whose latest funding round was 1 USD to 2 million USD.

### Prerequisites

* A Bright Data API key with Business Search access, stored in the `BRIGHTDATA_API_KEY` environment variable. See [Business Search quickstart](https://docs.brightdata.com/products/business-search/quickstart.md)
* For the Python tab, Python 3 with the `requests` package. For the Node.js tab, Node.js 18 or later

### Step 1: Find the companies

Send the company half of the question as a sentence in [Instant mode](https://docs.brightdata.com/products/business-search/introduction.md#search-modes). The view asks for `name`, which steps 2 and 3 use to match people to companies, and for `headquarters_city` and `funding_raised`, so you can check each company against the question:

```bash cURL theme={null}
curl --request POST "https://api.brightdata.com/search/company" \
  --header "Authorization: Bearer $BRIGHTDATA_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "mode": "instant",
    "query": "Technology companies headquartered in San Francisco whose latest funding round was between $1 and $2 million",
    "limit": 100,
    "view": { "fields": ["name", "headquarters_city", "funding_raised"] }
  }'
```

```python Python theme={null}
import os
import requests

API = "https://api.brightdata.com/search"
HEADERS = {
    "Authorization": f"Bearer {os.environ['BRIGHTDATA_API_KEY']}",
    "Content-Type": "application/json",
}

response = requests.post(
    f"{API}/company",
    headers=HEADERS,
    json={
        "mode": "instant",
        "query": "Technology companies headquartered in San Francisco whose latest funding round was between $1 and $2 million",
        "limit": 100,
        "view": {"fields": ["name", "headquarters_city", "funding_raised"]},
    },
)
response.raise_for_status()
companies = {
    doc["data"]["name"]
    for doc in response.json()["documents"]
    if "name" in doc["data"]
    and "san francisco" in doc["data"].get("headquarters_city", "").lower()
}
print(f"{len(companies)} companies found")
```

```javascript Node.js theme={null}
const API = "https://api.brightdata.com/search";
const HEADERS = {
  Authorization: `Bearer ${process.env.BRIGHTDATA_API_KEY}`,
  "Content-Type": "application/json",
};

const companyResponse = await fetch(`${API}/company`, {
  method: "POST",
  headers: HEADERS,
  body: JSON.stringify({
    mode: "instant",
    query: "Technology companies headquartered in San Francisco whose latest funding round was between $1 and $2 million",
    limit: 100,
    view: { fields: ["name", "headquarters_city", "funding_raised"] },
  }),
});
if (!companyResponse.ok) throw new Error(await companyResponse.text());

const companies = new Set();
for (const doc of (await companyResponse.json()).documents) {
  const city = (doc.data.headquarters_city ?? "").toLowerCase();
  if (doc.data.name && city.includes("san francisco")) companies.add(doc.data.name);
}
console.log(`${companies.size} companies found`);
```

Instant can return companies headquartered outside San Francisco, so the Python and Node.js code keep only companies whose `headquarters_city` contains San Francisco. Instant returns up to the first 100 matches. For a shorter list ranked by how well each company answers the sentence, send the same body with `"mode": "smart"` and `"limit": 10`. Smart costs more per search. See [Business Search pricing](https://docs.brightdata.com/products/business-search/pricing.md).

### Step 2: Search for people at those companies

Send people searches in [Ludicrous mode](https://docs.brightdata.com/products/business-search/introduction.md#search-modes), because the input is now a list of company names from step 1 rather than a sentence. Each request combines the people condition, a CEO title in this example, with up to 10 company names, as `or` conditions on `current_company_name`:

```bash cURL theme={null}
curl --request POST "https://api.brightdata.com/search/people" \
  --header "Authorization: Bearer $BRIGHTDATA_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "mode": "ludicrous",
    "query": {
      "and": [
        {
          "or": [
            { "text": { "current_title": "CEO" } },
            { "text": { "current_title": { "value": "chief executive officer", "mode": "all" } } }
          ]
        },
        {
          "or": [
            { "text": { "current_company_name": { "value": "COMPANY_NAME_1", "mode": "all" } } },
            { "text": { "current_company_name": { "value": "COMPANY_NAME_2", "mode": "all" } } }
          ]
        }
      ]
    },
    "limit": 100,
    "view": { "fields": ["current_title", "current_company_name"] }
  }'
```

```python Python theme={null}
ceo_title = {
    "or": [
        {"text": {"current_title": "CEO"}},
        {"text": {"current_title": {"value": "chief executive officer", "mode": "all"}}},
    ]
}

names = sorted(companies)
people = {}
for start in range(0, len(names), 10):
    batch = names[start:start + 10]
    response = requests.post(
        f"{API}/people",
        headers=HEADERS,
        json={
            "mode": "ludicrous",
            "query": {
                "and": [
                    ceo_title,
                    {
                        "or": [
                            {"text": {"current_company_name": {"value": name, "mode": "all"}}}
                            for name in batch
                        ]
                    },
                ]
            },
            "limit": 100,
            "view": {"fields": ["current_title", "current_company_name"]},
        },
    )
    response.raise_for_status()
    for doc in response.json()["documents"]:
        people[doc["bright_id"]] = doc["data"]

print(f"{len(people)} candidate profiles found")
```

```javascript Node.js theme={null}
const ceoTitle = {
  or: [
    { text: { current_title: "CEO" } },
    { text: { current_title: { value: "chief executive officer", mode: "all" } } },
  ],
};

const names = [...companies];
const people = new Map();
for (let start = 0; start < names.length; start += 10) {
  const batch = names.slice(start, start + 10);
  const peopleResponse = await fetch(`${API}/people`, {
    method: "POST",
    headers: HEADERS,
    body: JSON.stringify({
      mode: "ludicrous",
      query: {
        and: [
          ceoTitle,
          { or: batch.map((name) => ({ text: { current_company_name: { value: name, mode: "all" } } })) },
        ],
      },
      limit: 100,
      view: { fields: ["current_title", "current_company_name"] },
    }),
  });
  if (!peopleResponse.ok) throw new Error(await peopleResponse.text());
  for (const doc of (await peopleResponse.json()).documents) {
    people.set(doc.bright_id, doc.data);
  }
}
console.log(`${people.size} candidate profiles found`);
```

The Python and Node.js code send one request per batch of 10 names and key the results on `bright_id`, so a profile returned by two batches is kept once. In the cURL tab, replace `COMPANY_NAME_1` and `COMPANY_NAME_2` with company names from step 1, and add one condition per name. Each request is a separate billed search, so 100 companies cost 11 searches in total.

### Step 3: Keep the profiles whose company matches

Keep only the profiles whose `current_company_name` is exactly one of the names from step 1. With cURL, compare the two values in the step 1 and step 2 responses:

```python Python theme={null}
ceos = [p for p in people.values() if p.get("current_company_name") in companies]

for person in ceos:
    print(f"{person['current_title']} at {person['current_company_name']}")
```

```javascript Node.js theme={null}
const ceos = [...people.values()].filter((p) => companies.has(p.current_company_name));

for (const person of ceos) {
  console.log(`${person.current_title} at ${person.current_company_name}`);
}
```

The step 2 search is not enough on its own. `current_company_name` is a text field, so a condition matches every profile whose company name contains the words: `Acme` also matches `Acme Robotics`. Comparing the full name drops those profiles, and drops profiles with no `current_company_name`. The two searches share no identifier: a company record's `company_id` and a people record's `current_company_id` are different values, so the name is the only field both sides return.

Review the list before you use it. The `text` condition on `current_title` also matches titles that only contain CEO, such as Assistant to CEO. A company name can also belong to more than one company, and matching on the name cannot tell them apart.
