Overview
This node integrates with the OpenSearch API to manage documents and indexes. Specifically, for the Document - Create operation, it allows users to add new documents to a specified index in OpenSearch. This is useful when you want to programmatically insert data into an OpenSearch index for search, analytics, or storage purposes.
Common scenarios include:
- Adding new records from external sources (e.g., form submissions, CRM data) into an OpenSearch index.
- Bulk importing datasets into OpenSearch for indexing.
- Dynamically creating documents based on workflow input data.
For example, you might use this node to create a document representing a customer order in an "orders" index, mapping fields like order ID, customer name, and order details.
Properties
Name | Meaning |
---|---|
Index ID | The identifier of the OpenSearch index where the new document will be added. |
Data to Send | How to provide the document data: either define each field manually below or automatically map input data properties to document fields if their names match. |
Inputs to Ignore | When using auto-mapping, a comma-separated list of input property names to exclude from being sent as document fields. Leave empty to send all input properties. |
Fields to Send | (Shown if defining fields manually) A collection of field name/value pairs specifying the exact data to include in the new document. |
Additional Fields | Optional extra parameters for document creation: - Document ID: specify a custom ID for the document. - Routing: shard routing value. - Timeout: how long to wait for active shards (default "1m"). |
Options | Additional options: - Bulk Create: whether to use bulk API for multiple documents. - Pipeline ID: ID of a preprocessing pipeline to apply. - Refresh: controls shard refresh behavior ("true", "wait_for", "false"). |
Output
The node outputs JSON data representing the result of the document creation request(s). For each created document, the output typically includes metadata such as the document ID and status returned by OpenSearch.
If bulk creation is enabled, the output contains an array of results corresponding to each document in the bulk request.
No binary data output is produced by this operation.
Dependencies
- Requires an active connection to an OpenSearch instance.
- Needs an API authentication credential configured in n8n to authorize requests to OpenSearch.
- Uses OpenSearch REST API endpoints for document management.
Troubleshooting
- Error: Invalid JSON in 'Query' option — This can occur if JSON input fields are malformed. Ensure any JSON strings provided in options are valid.
- Document ID conflicts — If specifying a Document ID that already exists, the operation may overwrite or fail depending on OpenSearch settings.
- Bulk operation errors — When using bulk create, partial failures may occur. The node handles these by either continuing on failure (if enabled) or throwing an error with details.
- Timeouts — If the timeout period is too short, operations may fail waiting for active shards. Adjust the timeout setting accordingly.
- Authentication errors — Verify that the API key or credentials used have sufficient permissions to write documents to the target index.