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

# Boolean Search

> Use boolean queries to build precise LinkedIn and database sourcing searches.

The `boolean_query` parameter lets you write advanced search expressions using standard boolean operators. It is supported on both the LinkedIn search and database search endpoints.

## Supported operators

| Operator | Description           | Example                            |
| -------- | --------------------- | ---------------------------------- |
| `AND`    | Both terms must match | `Python AND Java`                  |
| `OR`     | Either term can match | `React OR Vue`                     |
| `NOT`    | Exclude a term        | `NOT Intern`                       |
| `"..."`  | Exact phrase match    | `"Software Engineer"`              |
| `( )`    | Group expressions     | `(Python OR Java) AND NOT Angular` |

## Operator precedence

From highest to lowest: `NOT` > `AND` > `OR`. Use parentheses to override.

```
# Without parentheses — AND binds tighter than OR
Python OR Java AND Senior
# Interpreted as: Python OR (Java AND Senior)

# With parentheses — explicit grouping
(Python OR Java) AND Senior
# Matches profiles with (Python or Java) AND Senior
```

## Examples

### Find engineers with specific skills

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://app.leonar.app/api/v1/sourcing/linkedin/search" \
    -H "Authorization: Bearer leo_your_api_key" \
    -H "Content-Type: application/json" \
    -d '{
      "project_id": "your-project-id",
      "account_id": "your-account-id",
      "boolean_query": "(Python OR Java) AND \"Software Engineer\" AND NOT Intern"
    }'
  ```

  ```typescript TypeScript theme={null}
  const response = await fetch("https://app.leonar.app/api/v1/sourcing/linkedin/search", {
    method: "POST",
    headers: {
      Authorization: "Bearer leo_your_api_key",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      project_id: "your-project-id",
      account_id: "your-account-id",
      boolean_query: '(Python OR Java) AND "Software Engineer" AND NOT Intern',
    }),
  });
  ```

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

  response = requests.post(
      "https://app.leonar.app/api/v1/sourcing/linkedin/search",
      headers={
          "Authorization": "Bearer leo_your_api_key",
          "Content-Type": "application/json",
      },
      json={
          "project_id": "your-project-id",
          "account_id": "your-account-id",
          "boolean_query": '(Python OR Java) AND "Software Engineer" AND NOT Intern',
      },
  )
  ```
</CodeGroup>

### Combine boolean query with other filters

`boolean_query` can be used alongside other filter fields like `job_titles`, `companies`, or `location_ids`. The boolean query applies to the keyword/full-text dimension while other filters apply to their respective structured fields.

```bash theme={null}
curl -X POST "https://app.leonar.app/api/v1/sourcing/linkedin/search" \
  -H "Authorization: Bearer leo_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "project_id": "your-project-id",
    "account_id": "your-account-id",
    "boolean_query": "\"Machine Learning\" OR \"Deep Learning\" AND NOT PhD",
    "years_experience": { "min": 3, "max": 10 },
    "location_ids": { "103644278": "United States" }
  }'
```

### Search the people database

Boolean queries also work on the database search endpoint:

```bash theme={null}
curl -X POST "https://app.leonar.app/api/v1/sourcing/database/search" \
  -H "Authorization: Bearer leo_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "project_id": "your-project-id",
    "boolean_query": "\"Product Manager\" AND (B2B OR SaaS) AND NOT Junior"
  }'
```

## Common patterns

| Use case             | Query                                                           |
| -------------------- | --------------------------------------------------------------- |
| Multiple roles       | `"Software Engineer" OR "Backend Developer" OR "Full Stack"`    |
| Skill combination    | `(React OR Angular OR Vue) AND TypeScript`                      |
| Exclude seniority    | `"Data Scientist" AND NOT (Junior OR Intern OR Entry)`          |
| Exact company + role | `"Goldman Sachs" AND ("Vice President" OR Director)`            |
| Industry targeting   | `(FinTech OR "Financial Technology") AND "Head of Engineering"` |

## Syntax rules

* Operators `AND`, `OR`, `NOT` must be **uppercase**
* Parentheses must be balanced
* Quoted phrases must have matching opening and closing `"`
* Operators cannot be consecutive (`AND AND` is invalid)
* A query cannot start with `AND` or `OR`

## Endpoints that support boolean queries

| Endpoint                         | Parameter       |
| -------------------------------- | --------------- |
| `POST /sourcing/linkedin/search` | `boolean_query` |
| `POST /sourcing/database/search` | `boolean_query` |
