Elasticsearch
App · Databases · 5 actions
Create, read, update, search and delete documents in your Elasticsearch indices, and start a workflow when a document is added.
Actions
| Action | What it does |
|---|---|
| Create document | Add a new document to an index. |
| Delete document | Delete a document from an index by its Document ID. |
| Get document | Retrieve a single document from an index by its Document ID. |
| Search documents | Find documents in an index by words they contain, by the value of one field, or both, such as every order whose status is pending. |
| Update document | Update a document by its Document ID. |
Create document
Add a new document to an index. Provide a Document ID to control the id (the action fails if that id already exists; use Update document to change an existing one), or leave it blank to let Elasticsearch generate one.
Inputs
- Index
indextextRequired - Name of the index to add the document to (for example 'products'). Elasticsearch creates the index automatically if it does not exist yet.
- Document
documentobjectRequired - The document to store, as field/value pairs (for example, name: 'Wireless Headphones', price: 79.99).
- Document ID
document_idtext - Optional unique id for the new document. When blank, Elasticsearch generates one and returns it.
Outputs
document_idtext- Id of the created document
indextext- Index the document was written to
resulttext- Elasticsearch write result, e.g. 'created'
versionnumber- Document version assigned by Elasticsearch
Example output
{
"document_id": "1",
"index": "products",
"result": "created",
"version": 1
}Delete document
Delete a document from an index by its Document ID.
Inputs
- Index
indextextRequired - The index the document lives in.
- Document ID
document_idtextRequired - The document's unique id within the index.
Outputs
document_idtext- Id of the deleted document
indextext- Index the document was deleted from
resulttext- Elasticsearch result, e.g. 'deleted'
Example output
{
"document_id": "1",
"index": "products",
"result": "deleted"
}Get document
Retrieve a single document from an index by its Document ID.
Inputs
- Index
indextextRequired - The index the document lives in.
- Document ID
document_idtextRequired - The document's unique id within the index.
Outputs
documentobject- The document's stored fields (its _source)
document_idtext- Id of the document
indextext- Index the document belongs to
versionnumber- Current document version
Example output
{
"document": {
"name": "Wireless Headphones",
"price": 79.99
},
"document_id": "1",
"index": "products",
"version": 1
}Search documents
Find documents in an index by words they contain, by the value of one field, or both, such as every order whose status is pending. Leave both empty to list the index's documents. Returns up to 100, sorted by a field you choose or by how well they match.
Inputs
- Index
indextextRequired - The index the document lives in.
- Search for
search_texttext - Words to look for anywhere in the documents, such as wireless headphones. Every word must appear. Leave it empty to match on a field alone, or to list documents.
- Field
fieldtext - Only documents whose value in this field matches Value, such as status. Use dots for a field inside another, such as customer.email.
- Value
valuetext - The value Field must have, such as pending. Needed when Field is filled in.
- Sort by
sort_bytext - A field to put the documents in order by, such as created_at or price. Leave it empty to put the best matches first.
- Order
sort_ordertext - Which end of Sort by comes first.One of:
desc(Highest or newest first),asc(Lowest or oldest first). Default:desc. - Limit
limitnumber - The most documents to return, from 1 to 100.Default:
10.
Outputs
countnumber- How many documents were returned
documentslist- The documents found, each with its index, document_id, score (how well it matched) and document (its stored fields)
indextext- The index that was searched
totalnumber- How many documents match in all, which can be more than were returned
Example output
{
"count": 1,
"documents": [
{
"document": {
"name": "Wireless Headphones",
"price": 79.99
},
"document_id": "1",
"index": "products",
"score": 1.3862942
}
],
"index": "products",
"total": 1
}Update document
Update a document by its Document ID. The fields you provide are merged into the stored document, leaving its other fields unchanged.
Inputs
- Index
indextextRequired - Name of the index the document lives in (for example 'products'). With 'Create if missing' on, a new index is created automatically if it does not exist yet.
- Document ID
document_idtextRequired - The document's unique id within the index.
- Fields to update
documentobjectRequired - The fields to add or change, as field/value pairs (for example, price: 69.99). Fields you omit are left as they are.
- Create if missing
upserttrue/false - When on, a document that does not exist yet is created from these fields instead of failing.Default:
false.
Outputs
document_idtext- Id of the updated document
indextext- Index the document belongs to
resulttext- Elasticsearch write result, e.g. 'updated' or 'noop' when the fields already matched
versionnumber- Document version after the update
Example output
{
"document_id": "1",
"index": "products",
"result": "updated",
"version": 2
}