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

# Search endpoint

> Example OpenSearch DSL queries for the Search Profiles and Search Companies endpoints.

These examples target the [Search Profiles](/docs/endpoints/v3/search-profiles) endpoint. The same query patterns apply to [Search Companies](/docs/endpoints/v3/search-companies) — swap the field paths for `companies.*`.

<Tip>
  Looking for a reference on AND/OR logic, exact phrase matching, or `.raw` vs. text fields? See the [Query operators](/docs/examples/query-operators) cheat sheet.
</Tip>

## Basic patterns

### Search for profiles with an email address

Retrieve up to 5 profiles with an email on record. Uses an `exists` query.

```json theme={null}
{
  "query": {
    "exists": {
      "field": "profile_info.emails"
    }
  },
  "limit": 5
}
```

### Search for Data Science professionals (full text)

`match` performs a full-text search and may include adjacent titles.

```json theme={null}
{
  "query": {
    "match": {
      "profile_info.current_title": {
        "query": "data scientist",
        "operator": "AND"
      }
    }
  },
  "limit": 10
}
```

### Exact-match search on a title

`profile_info.current_title` is mapped as both `text` and `keyword`. Use `term` against the `.raw` field for an exact match.

```json theme={null}
{
  "query": {
    "term": {
      "profile_info.current_title.raw": {
        "value": "Data Scientist"
      }
    }
  },
  "limit": 10
}
```

### Restrict to network connections only

`in_network_only: true` returns only profiles connected to your team — ideal for warm outreach.

```json theme={null}
{
  "in_network_only": true,
  "limit": 100,
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "profile_info.job_title": "Product Manager"
          }
        }
      ],
      "filter": [
        {
          "term": {
            "profile_info.job_seniorities": "senior"
          }
        }
      ]
    }
  }
}
```

## Combining conditions

### Multiple `must` conditions

Find all software developers working at The Swarm.

```json theme={null}
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "profile_info.current_title": {
              "query": "software developer"
            }
          }
        },
        {
          "match": {
            "profile_info.current_company_name": {
              "query": "The Swarm"
            }
          }
        }
      ]
    }
  }
}
```

### Range filter combined with a term filter

Profiles in the Information Technology and Services industry whose current job was updated in a date range.

```json theme={null}
{
  "query": {
    "bool": {
      "must": [
        {
          "range": {
            "profile_info.current_job_updated_at": {
              "gte": "2024-05-12",
              "lte": "2024-05-18"
            }
          }
        },
        {
          "term": {
            "profile_info.current_company_industry": {
              "value": "Information Technology and Services"
            }
          }
        }
      ]
    }
  }
}
```

## Nested queries (work experience)

### Profiles in the US who previously held a product role at Google

Uses a `nested` query against `profile_info.experience` and excludes current roles.

```json theme={null}
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "current_location": {
              "query": "United States"
            }
          }
        },
        {
          "nested": {
            "path": "profile_info.experience",
            "query": {
              "bool": {
                "must": [
                  {
                    "match": {
                      "profile_info.experience.company.name": {
                        "query": "Google"
                      }
                    }
                  },
                  {
                    "match": {
                      "profile_info.experience.title.name": {
                        "query": "Product"
                      }
                    }
                  },
                  {
                    "bool": {
                      "must_not": [
                        {
                          "exists": {
                            "field": "profile_info.experience.is_current"
                          }
                        }
                      ]
                    }
                  }
                ]
              }
            }
          }
        }
      ]
    }
  }
}
```

### Anyone who has ever worked at Google

```json theme={null}
{
  "query": {
    "nested": {
      "path": "profile_info.experience",
      "query": {
        "match": {
          "profile_info.experience.company.name.raw": {
            "query": "Google"
          }
        }
      }
    }
  }
}
```

### Worked at Google in the past, not currently there

```json theme={null}
{
  "query": {
    "bool": {
      "must": [
        {
          "nested": {
            "path": "profile_info.experience",
            "query": {
              "match": {
                "profile_info.experience.company.name.raw": {
                  "query": "Google"
                }
              }
            }
          }
        }
      ],
      "must_not": [
        {
          "match": {
            "profile_info.job_company_name.raw": {
              "query": "Google"
            }
          }
        }
      ]
    }
  }
}
```

## Recent job changes

For full coverage of querying job changes (promotions vs company moves, polling patterns), see [Daily Job Changes](/docs/signals/daily-job-changes).

```json theme={null}
{
  "query": {
    "bool": {
      "filter": [
        {
          "range": {
            "profile_info.current_job_updated_at": {
              "gte": "2025-06-01"
            }
          }
        }
      ]
    }
  }
}
```

## Pagination

Search returns up to 1000 results per page. Use the `pagination_token` from the previous response to retrieve the next page.

```json theme={null}
{
  "query": {
    "exists": {
      "field": "profile_info.emails"
    }
  },
  "limit": 5,
  "pagination_token": "eyJzZWFyY2hfYWZ0ZXIiOlt7ImZpZWxkIjoiX3Njb3JlIiwidmFsdWUiOjF9LHsiZmllbGQiOiJwcm9maWxlX2luZm8uaWQiLCJ2YWx1ZSI6IjAwMDE2MTU4LWYyY2EtNDYzZC05YWEzLTIyOWZkMzk0ZWQ0MSJ9XX0="
}
```

See [Pagination](/docs/api-reference/pagination) for full details.
