POST /v2/indices/{index public key}/documents/
Create a new document to the index.
By default, the Documents API endpoint creates a random id for each new document. If you want to define the id for the document or generate the id using the URL field, use the Update Document endpoint.
The request body should be a JSON object describing the document contents.
{ "custom_fields": { "title": "Example product", "description": "Description for example product", "price_cents": 599, "average_customer_rating": 4.5, "release_date": 1589200255 } }
Field | Description | Type | Notes |
---|---|---|---|
Standard field | Any of the standard fields described here except the URL. | Depends on the field | Each field should be a separate key-value pair. |
custom_fields | Top level | A map of custom fields key value pairs | Supported data-types: text, integer, and double. |
{ "id": "123", "url": "https://www.example.com/page.html", "language": "en", "title": "An example article title", "main_content": "The text content of the article. The automatic highlight in search results will only be generated from the content of this field.", "custom_fields": { "image_url": "https://www.example.com/page.png", "article_categories": ["Block post", "Article"] } }
Data types for custom fields are automatically collected from the fields content/value. Supported data types are:
Dates should be defined as UNIX timestamps with integer values.
Please note that once you have defined a specific data type for the custom field, the data type cannot be changed.
Indexing unsupported values will fail. If you have defined an unsupported data type, create a new custom field with a different name.
A request to create a new document adds the document to a queue. On success, the endpoint will return a response HTTP 201 Created, with a URL pointing to the created document in the response header “Location”. It might take a few seconds for the document to become available.
We’re always happy to help with code or other questions you might have. Search our documentation, contact support, or connect with our sales team.