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

# Relationships endpoint

> Example OpenSearch DSL queries for the Relationships endpoint.

These examples target the [Relationships](/docs/endpoints/v3/relationships) endpoint. The request body is a standard OpenSearch DSL `query` — combine clauses with `bool` (`must`, `should`, `filter`, `must_not`) as needed.

For the full list of indexed fields you can query against, see [OpenSearch Profile Mappings (v3)](/docs/enrichment-data/profile/mappings-v3).

<Note>
  **Two different origin vocabularies.** The query-side field `team_connections.origins` and the response-side field `connections[].sources[].origin` use **different value sets**. Use the values listed below when querying. For the response vocabulary, see the [sources field FAQ](/docs/getting-started/faq#what-does-the-sources-field-in-connections-mean).
</Note>

## Discovery queries

### Connections to people working at a specific company

Find people in your network who currently work at a company with a given domain.

```json theme={null}
{
  "query": {
    "term": {
      "profile_info.current_company_website": {
        "value": "theswarm.com"
      }
    }
  }
}
```

### Connections to a specific person

Identify who in your network is connected to a specific person, by LinkedIn username.

```json theme={null}
{
  "query": {
    "term": {
      "profile_info.linkedin_usernames": {
        "value": "connorsdavid"
      }
    }
  }
}
```

### Connections to senior software engineers at selected companies

Combine seniority, role, and company filters with a `bool.must` clause.

```json theme={null}
{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "profile_info.current_seniorities": {
              "value": "senior"
            }
          }
        },
        {
          "match": {
            "profile_info.current_title": {
              "query": "software engineer",
              "operator": "AND"
            }
          }
        },
        {
          "terms": {
            "profile_info.current_company_website": [
              "apple.com",
              "google.com",
              "microsoft.com"
            ]
          }
        }
      ]
    }
  }
}
```

## Filter by a specific connector

The top-level `connected_users` field (`keyword`) holds the IDs of the team members each connection originates from. Use a `term` query to limit results to a specific connector — useful when you want to see who a single team member is connected to.

Replace the value with the user ID of the connector (find your team members' IDs in **Team Settings → Members**).

```json theme={null}
{
  "query": {
    "term": {
      "connected_users": {
        "value": "4a9a0f84-9edf-48eb-a832-bc0594d77d70"
      }
    }
  }
}
```

To filter by multiple connectors at once, use `terms` with an array of IDs.

## Filtering by team connection origin

The profile document includes a nested `team_connections` field that stores how each connection was synced. Use a [nested query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-nested-query.html) against `team_connections.origins`, typically scoped to your `team_connections.team_id`, to filter results.

Accepted `team_connections.origins` values (provisional, may change): `csv`, `plugin`, `overlaps`, `google`, `google-calendar`, `user-profile`, `manual-csv`, `education-overlaps`, `investor-overlaps`, `manual-url`.

### Connections from work or education overlaps for a specific team

Scopes the origin filter to your team using `team_connections.team_id`. Replace `<your team id>` with your team ID.

```json theme={null}
{
  "query": {
    "bool": {
      "must": [
        {
          "nested": {
            "path": "team_connections",
            "query": {
              "bool": {
                "must": [
                  {
                    "term": {
                      "team_connections.team_id": {
                        "value": "<your team id>"
                      }
                    }
                  },
                  {
                    "terms": {
                      "team_connections.origins": ["overlaps"]
                    }
                  }
                ]
              }
            }
          }
        }
      ]
    }
  }
}
```

To filter by multiple origins, pass them in the `terms` array — for example `["overlaps", "education-overlaps"]`.

### Combine an origin filter with a role filter

Find product managers in your team's network who are connected via the LinkedIn plugin or shared work history.

```json theme={null}
{
  "query": {
    "bool": {
      "must": [
        {
          "nested": {
            "path": "team_connections",
            "query": {
              "bool": {
                "must": [
                  {
                    "term": {
                      "team_connections.team_id": {
                        "value": "<your team id>"
                      }
                    }
                  },
                  {
                    "terms": {
                      "team_connections.origins": ["plugin", "overlaps"]
                    }
                  }
                ]
              }
            }
          }
        },
        {
          "match": {
            "profile_info.current_title": {
              "query": "product manager",
              "operator": "AND"
            }
          }
        }
      ]
    }
  }
}
```
