> ## 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

> Business Search query examples for questions one request cannot answer, such as finding CEOs of funded companies in a city with two chained searches.

This page shows how to answer prospecting questions with Business Search, including questions that need a company search and a people search in sequence.

## How to find CEOs of companies by funding and location

To find the CEOs of technology companies headquartered in San Francisco whose latest funding round was 1 USD to 2 million USD, run a company search for the companies first, then a people search for the CEOs at those companies.

One Business Search request cannot answer this question. A people search filters only on the [people searchable fields](/products/business-search/people-search#searchable-fields), such as `current_title` and `current_company_name`. Funding and headquarters are [company searchable fields](/products/business-search/company-search#searchable-fields). A people record can return `current_company_funding_raised` in its view, but a people search cannot filter on it.

### Prerequisites

* A Bright Data API key with Business Search access, stored in the `BRIGHTDATA_API_KEY` environment variable. See [Business Search quickstart](/products/business-search/quickstart)
* 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](/products/business-search/introduction#search-modes). The view asks for `company_id`, which step 3 uses to match people to companies, and for `headquarters_city` and `funding_raised`, so you can check each company against the question:

<CodeGroup>
  ```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": ["company_id", "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": ["company_id", "name", "headquarters_city", "funding_raised"]},
      },
  )
  response.raise_for_status()
  companies = {
      str(doc["data"]["company_id"]): doc["data"]["name"]
      for doc in response.json()["documents"]
      if "company_id" in doc["data"] and "name" in doc["data"]
  }
  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: ["company_id", "name", "headquarters_city", "funding_raised"] },
    }),
  });
  if (!companyResponse.ok) throw new Error(await companyResponse.text());

  const companies = new Map();
  for (const doc of (await companyResponse.json()).documents) {
    if (doc.data.company_id != null && doc.data.name) {
      companies.set(String(doc.data.company_id), doc.data.name);
    }
  }
  console.log(`${companies.size} companies found`);
  ```
</CodeGroup>

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](/products/business-search/pricing).

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

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

<CodeGroup>
  ```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", "current_company_id"] }
    }'
  ```

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

  names = list(companies.values())
  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", "current_company_id"]},
          },
      )
      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.values()];
  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", "current_company_id"] },
      }),
    });
    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`);
  ```
</CodeGroup>

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_id` is one of the `company_id` values from step 1. With cURL, compare the two values in the step 1 and step 2 responses:

<CodeGroup>
  ```python Python theme={null}
  ceos = [p for p in people.values() if str(p.get("current_company_id")) in companies]

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

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

  for (const person of ceos) {
    console.log(`${person.current_title} at ${companies.get(String(person.current_company_id))}`);
  }
  ```
</CodeGroup>

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`. Matching on the company ID drops those profiles, and drops profiles with no `current_company_id`.
