# Elasticsearch DSL: Base Company API

{% columns %}
{% column width="16.666666666666664%" %}
Data type:

Query type:

URL:
{% endcolumn %}

{% column %}
Base Company

Elasticsearch DSL

<https://api.coresignal.com/cdapi/v2/company\\_base/search/es\\_dsl>
{% endcolumn %}
{% endcolumns %}

***

## Overview

Use the `/v2/company_base/search/es_dsl` endpoint for more sophisticated queries and retrieve company data.

<table data-view="cards"><thead><tr><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td>General Elasticsearch DSL information and usage tips</td><td><a href="../../../api-introduction/requests/elasticsearch-dsl">elasticsearch-dsl</a></td></tr></tbody></table>

## Elasticsearch schema

<details>

<summary>Elasticsearch schema</summary>

{% code title="Endpoint schema" expandable="true" %}

```json
{
    "mappings": {
        "properties": {
            "id": {
                "type": "long"
            },
            "url": {
                "type": "text",
                "fields": {
                    "exact": {
                        "type": "keyword"
                    }
                }
            },
            "hash": {
                "type": "keyword",
                "index": false,
                "doc_values": false
            },
            "name": {
                "type": "text",
                "fields": {
                    "exact": {
                        "type": "keyword"
                    }
                }
            },
            "website": {
                "type": "text",
                "fields": {
                    "exact": {
                        "type": "keyword",
                        "null_value": "NULL"
                    },
                    "filter": {
                        "type": "text"
                    }
                }
            },
            "size": {
                "type": "keyword",
                "null_value": "NULL"
            },
            "industry": {
                "type": "text",
                "fields": {
                    "exact": {
                        "type": "keyword",
                        "null_value": "NULL"
                    }
                }
            },
            "description": {
                "type": "text"
            },
            "followers": {
                "type": "long",
                "index": false,
                "doc_values": false
            },
            "founded": {
                "type": "long",
                "null_value": 1000
            },
            "headquarters_city": {
                "type": "keyword",
                "index": false,
                "doc_values": false
            },
            "headquarters_country": {
                "type": "keyword",
                "index": false,
                "doc_values": false
            },
            "headquarters_state": {
                "type": "keyword",
                "index": false,
                "doc_values": false
            },
            "headquarters_street1": {
                "type": "text",
                "index": false
            },
            "headquarters_street2": {
                "type": "text",
                "index": false
            },
            "headquarters_zip": {
                "type": "keyword",
                "index": false,
                "doc_values": false
            },
            "headquarters_country_parsed": {
                "type": "keyword",
                "null_value": "NULL"
            },
            "headquarters_new_address": {
                "type": "text",
                "fields": {
                    "exact": {
                        "type": "keyword",
                        "null_value": "NULL"
                    }
                }
            },
            "headquarters_country_restored": {
                "type": "keyword",
                "index": false,
                "doc_values": false
            },
            "logo_url": {
                "type": "keyword",
                "index": false,
                "doc_values": false
            },
            "last_response_code": {
                "type": "long",
                "index": false,
                "doc_values": false
            },
            "source_id": {
                "type": "long"
            },
            "created": {
                "type": "date",
                "format": "yyyy-MM-dd HH:mm:ss"
            },
            "last_updated": {
                "type": "date",
                "format": "yyyy-MM-dd HH:mm:ss"
            },
            "type": {
                "type": "text"
            },
            "employees_count": {
                "type": "long",
                "null_value": -1
            },
            "company_shorthand_name": {
                "type": "keyword"
            },
            "company_shorthand_name_hash": {
                "type": "keyword",
                "index": false,
                "doc_values": false
            },
            "canonical_url": {
                "type": "text",
                "fields": {
                    "exact": {
                        "type": "keyword"
                    }
                }
            },
            "canonical_hash": {
                "type": "keyword",
                "index": false,
                "doc_values": false
            },
            "canonical_shorthand_name": {
                "type": "keyword"
            },
            "canonical_shorthand_name_hash": {
                "type": "keyword",
                "index": false,
                "doc_values": false
            },
            "deleted": {
                "type": "byte"
            },
            "last_updated_ux": {
                "type": "long",
                "index": false,
                "doc_values": false
            },
            "company_affiliated_collection": {
                "type": "nested",
                "properties": {
                    "id": {
                        "type": "long",
                        "index": false,
                        "doc_values": false
                    },
                    "company_id": {
                        "type": "long",
                        "index": false,
                        "doc_values": false
                    },
                    "affiliated_company_url": {
                        "type": "text",
                        "index": false
                    },
                    "affiliated_company_id": {
                        "type": "long",
                        "index": false,
                        "doc_values": false
                    },
                    "created": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss",
                        "index": false,
                        "doc_values": false
                    },
                    "last_updated": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss",
                        "index": false,
                        "doc_values": false
                    },
                    "deleted": {
                        "type": "byte",
                        "index": false,
                        "doc_values": false
                    }
                }
            },
            "company_also_viewed_collection": {
                "type": "nested",
                "properties": {
                    "id": {
                        "type": "long",
                        "index": false,
                        "doc_values": false
                    },
                    "company_id": {
                        "type": "long",
                        "index": false,
                        "doc_values": false
                    },
                    "viewed_company_url": {
                        "type": "text",
                        "index": false
                    },
                    "viewed_company_id": {
                        "type": "long",
                        "index": false,
                        "doc_values": false
                    },
                    "created": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss",
                        "index": false,
                        "doc_values": false
                    },
                    "last_updated": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss",
                        "index": false,
                        "doc_values": false
                    },
                    "deleted": {
                        "type": "byte",
                        "index": false,
                        "doc_values": false
                    }
                }
            },
            "company_financial_website_info_collection": {
                "type": "nested",
                "properties": {
                    "id": {
                        "type": "long"
                    },
                    "company_id": {
                        "type": "long",
                        "index": false,
                        "doc_values": false
                    },
                    "financial_website_url": {
                        "type": "text",
                        "fields": {
                            "exact": {
                                "type": "keyword"
                            }
                        }
                    },
                    "created": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss",
                        "index": false,
                        "doc_values": false
                    },
                    "last_updated": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss",
                        "index": false,
                        "doc_values": false
                    },
                    "deleted": {
                        "type": "byte",
                        "index": false,
                        "doc_values": false
                    }
                }
            },
            "company_featured_employees_collection": {
                "type": "nested",
                "properties": {
                    "id": {
                        "type": "long",
                        "index": false,
                        "doc_values": false
                    },
                    "company_id": {
                        "type": "long",
                        "index": false,
                        "doc_values": false
                    },
                    "url": {
                        "type": "text",
                        "index": false
                    },
                    "created": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss",
                        "index": false,
                        "doc_values": false
                    },
                    "last_updated": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss",
                        "index": false,
                        "doc_values": false
                    },
                    "deleted": {
                        "type": "byte",
                        "index": false,
                        "doc_values": false
                    }
                }
            },
            "company_featured_investors_collection": {
                "type": "nested",
                "properties": {
                    "id": {
                        "type": "long",
                        "index": false,
                        "doc_values": false
                    },
                    "company_id": {
                        "type": "long",
                        "index": false,
                        "doc_values": false
                    },
                    "investor_id": {
                        "type": "long",
                        "index": false,
                        "doc_values": false
                    },
                    "round_id": {
                        "type": "long",
                        "index": false,
                        "doc_values": false
                    },
                    "created": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss",
                        "index": false,
                        "doc_values": false
                    },
                    "last_updated": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss",
                        "index": false,
                        "doc_values": false
                    },
                    "deleted": {
                        "type": "byte",
                        "index": false,
                        "doc_values": false
                    },
                    "company_investors_list": {
                        "properties": {
                            "id": {
                                "type": "long",
                                "index": false,
                                "doc_values": false
                            },
                            "name": {
                                "type": "text",
                                "index": false
                            },
                            "hash": {
                                "type": "keyword",
                                "index": false,
                                "doc_values": false
                            },
                            "financial_website_url": {
                                "type": "text",
                                "index": false
                            },
                            "created": {
                                "type": "date",
                                "format": "yyyy-MM-dd HH:mm:ss",
                                "index": false,
                                "doc_values": false
                            },
                            "last_updated": {
                                "type": "date",
                                "format": "yyyy-MM-dd HH:mm:ss",
                                "index": false,
                                "doc_values": false
                            }
                        }
                    }
                }
            },
            "company_locations_collection": {
                "type": "nested",
                "properties": {
                    "id": {
                        "type": "long",
                        "index": false,
                        "doc_values": false
                    },
                    "company_id": {
                        "type": "long",
                        "index": false,
                        "doc_values": false
                    },
                    "location_address": {
                        "type": "text",
                        "index": false
                    },
                    "is_primary": {
                        "type": "byte",
                        "index": false,
                        "doc_values": false
                    },
                    "created": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss",
                        "index": false,
                        "doc_values": false
                    },
                    "last_updated": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss",
                        "index": false,
                        "doc_values": false
                    },
                    "deleted": {
                        "type": "byte",
                        "index": false,
                        "doc_values": false
                    }
                }
            },
            "company_similar_collection": {
                "type": "nested",
                "properties": {
                    "id": {
                        "type": "long",
                        "index": false,
                        "doc_values": false
                    },
                    "company_id": {
                        "type": "long",
                        "index": false,
                        "doc_values": false
                    },
                    "url": {
                        "type": "text",
                        "index": false
                    },
                    "created": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss",
                        "index": false,
                        "doc_values": false
                    },
                    "last_updated": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss",
                        "index": false,
                        "doc_values": false
                    },
                    "deleted": {
                        "type": "byte",
                        "index": false,
                        "doc_values": false
                    }
                }
            },
            "company_specialties_collection": {
                "type": "nested",
                "properties": {
                    "id": {
                        "type": "long"
                    },
                    "company_id": {
                        "type": "long",
                        "index": false,
                        "doc_values": false
                    },
                    "specialty": {
                        "type": "text"
                    },
                    "created": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss",
                        "index": false,
                        "doc_values": false
                    },
                    "last_updated": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss",
                        "index": false,
                        "doc_values": false
                    },
                    "deleted": {
                        "type": "byte",
                        "index": false,
                        "doc_values": false
                    }
                }
            },
            "company_stock_info_collection": {
                "type": "nested",
                "properties": {
                    "id": {
                        "type": "long"
                    },
                    "company_id": {
                        "type": "long",
                        "index": false,
                        "doc_values": false
                    },
                    "ticker": {
                        "type": "text"
                    },
                    "exchange": {
                        "type": "keyword",
                        "index": false,
                        "doc_values": false
                    },
                    "created": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss",
                        "index": false,
                        "doc_values": false
                    },
                    "last_updated": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss",
                        "index": false,
                        "doc_values": false
                    },
                    "deleted": {
                        "type": "byte",
                        "index": false,
                        "doc_values": false
                    }
                }
            },
            "company_funding_rounds_collection": {
                "type": "nested",
                "properties": {
                    "id": {
                        "type": "long"
                    },
                    "last_round_investors_count": {
                        "type": "long"
                    },
                    "total_rounds_count": {
                        "type": "long",
                        "null_value": -1
                    },
                    "last_round_type": {
                        "type": "keyword"
                    },
                    "last_round_date": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||uuuu",
                        "null_value": "1000"
                    },
                    "last_round_money_raised": {
                        "type": "keyword"
                    },
                    "financial_website_url": {
                        "type": "keyword"
                    },
                    "created": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss"
                    },
                    "last_updated": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss"
                    },
                    "deleted": {
                        "type": "byte"
                    }
                }
            },
            "company_updates_collection": {
                "type": "nested",
                "properties": {
                    "id": {
                        "type": "long",
                        "index": false,
                        "doc_values": false
                    },
                    "company_id": {
                        "type": "long",
                        "index": false,
                        "doc_values": false
                    },
                    "urn": {
                        "type": "text",
                        "index": false
                    },
                    "followers": {
                        "type": "long",
                        "index": false,
                        "doc_values": false
                    },
                    "date": {
                        "type": "keyword",
                        "index": false,
                        "doc_values": false
                    },
                    "description": {
                        "type": "text",
                        "index": false
                    },
                    "reactions_count": {
                        "type": "long",
                        "index": false,
                        "doc_values": false
                    },
                    "comments_count": {
                        "type": "long",
                        "index": false,
                        "doc_values": false
                    },
                    "reshared_post_author": {
                        "type": "text",
                        "index": false
                    },
                    "reshared_post_author_url": {
                        "type": "text",
                        "index": false
                    },
                    "reshared_post_author_headline": {
                        "type": "text",
                        "index": false
                    },
                    "reshared_post_description": {
                        "type": "text",
                        "index": false
                    },
                    "reshared_post_followers": {
                        "type": "long",
                        "index": false,
                        "doc_values": false
                    },
                    "reshared_post_date": {
                        "type": "keyword",
                        "index": false,
                        "doc_values": false
                    },
                    "last_updated": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss",
                        "index": false,
                        "doc_values": false
                    },
                    "deleted": {
                        "type": "byte",
                        "index": false,
                        "doc_values": false
                    }
                }
            }
        }
    }
}

```

{% endcode %}

</details>

{% hint style="success" %}

#### Having trouble writing Elasticsearch queries on your own?

Explore **AI query builder** feature available in Self-service [playground](https://dashboard.coresignal.com/apis/company/playground). Write a prompt, and AI assistant will automatically convert it into a query.
{% endhint %}

## Sample request

{% code title="Request example" expandable="true" %}

```json
curl -X 'POST' \
'https://api.coresignal.com/cdapi/v2/company_base/search/es_dsl' \
  -H 'accept: application/json' \
  -H 'apikey: {API Key}' \
  -H 'Content-Type: application/json' \
  -d '{
   "query":{
      "bool":{
         "must":[
            {
               "query_string":{
                  "query":"2023",
                  "default_field":"founded",
                  "default_operator":"and"
               }
            }
         ]
      }
   }
}'
```

{% endcode %}

### Sorting options

Find several examples of the available sorting options. All information about the sorting is in the general [Elasticsearch DSL](https://docs.coresignal.com/api-introduction/requests/elasticsearch-dsl#sorting-options) topic.

{% tabs %}
{% tab title="Sort by score" %}
{% code title="Sort by score" %}

```json
{
    "query": {
      "match":{
         "name":{
            "query":"Example Company",
            "operator":"and"
         }
      }
   },
    "sort": [
        "_score"
    ]
}
```

{% endcode %}
{% endtab %}

{% tab title="Sort by id" %}
{% code title="Sort by id" %}

```json
{
   "query": {
      "bool": {
         "filter": [
            {
               "range": {
                  "employees_count": {
                     "gte": 100
                  }
               }
            }
         ]
      }
   },
   "sort": [
      "id"
   ]
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

#### Additional sorting fields

Base Company includes **additional numerical sorting options**. Sorting is made in descending order by a selected field. If several fields have the same value, sorting is made by the `last_updated` field. If the `last_updated` values are also the same, sorting is then done by the `id` field. Sorting fields are listed below:

* `employees_count`,
* `source_id`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.coresignal.com/company-api/base-company-api/endpoints/elasticsearch-dsl.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
