Elasticsearch
ToolJet allows you to connect to your Elasticsearch cluster to perform data read/write operations and execute various queries.
Connectionβ
To connect to an Elasticsearch data source in ToolJet, you can either click the + Add new data source button on the query panel or navigate to the Data Sources page in the ToolJet dashboard.
Please make sure the Host/IP of the database is accessible from your VPC if you have self-hosted ToolJet. If you are using ToolJet cloud, please whitelist our IP.
To connect to your Elasticsearch cluster, the following details are required:
- Host
- Port
- Username
- Password
ToolJet also supports SSL certificate-based connections:
- You can use either CA or Client certificates.
Querying Elasticsearchβ
- Click the + Add button in the query manager at the bottom of the editor and select the Elasticsearch data source added earlier.
- Choose the operation you want to perform on your Elasticsearch cluster.
Query results can be transformed using transformations. Refer to our transformations documentation for more details: link
Supported Operationsβ
ToolJet supports the following Elasticsearch operations:
- Search
- Index a Document
- Get a Document
- Update a Document
- Delete a Document
- Bulk Operation
- Count Documents
- Check Document Existence
- Multi Get
- Scroll Search
- Clear Scroll
- Get Cat Indices
- Get Cluster Health
Searchβ
This operation executes a search query and returns matching search hits. For more details, see the Elasticsearch search guide here.
Required Parameterβ
- Index: The name of the index to search in.
- Query: The search query in JSON format.
Optional Parameterβ
- Scroll: Scroll time.
Example:β
Index: books
Query:
{
"query": {
"match": {
"title": "The Great Gatsby"
}
},
"size": 20
}
Scroll: 1m # Can be in the format of 1m, 1h, 1d.
Index a Documentβ
This operation adds a JSON document to the specified index or data stream. For more details, see the Elasticsearch index guide here.
Required Parameterβ
- Index: The name of the index to add the document to
- Body: The document body in JSON format
Example:β
Index: books
Body:
{
"title": "1984",
"author": "George Orwell",
"year": 1949,
"genre": "Dystopian Fiction"
}
Get a Documentβ
This operation retrieves the specified JSON document from the index. For more details, see the Elasticsearch get guide here.
Required Parameterβ
- Index: The name of the index to get the document from
- Id: The ID of the document to retrieve
Example:β
Index: books
Id: FJXTSZEBsuzUn2y4wZ-W
Update a Documentβ
This operation updates a document using the specified script. For more details, see the Elasticsearch update guide here.
Required Parameterβ
- Index: The name of the index containing the document
- Id: The ID of the document to update
- Body: The update script or partial document in JSON format
Example:β
Index: books
Id: FJXTSZEBsuzUn2y4wZ-W
Body:
{
"doc": {
"title": "1984",
"author": "George Orwell",
"year": 1949,
"genre": "Fiction"
}
}
Delete a Documentβ
This operation removes a JSON document from the specified index. For more details, see the Elasticsearch delete guide here.
Required Parameterβ
- Index: The name of the index containing the document
- Id: The ID of the document to delete
Example:β
Index: books
Id: FJXTSZEBsuzUn2y4wZ-W
Bulk Operationβ
This operation performs multiple index/update/delete operations in a single API call. For more details, see the Elasticsearch bulk guide here.
Required Parameterβ
- Operations: The bulk operations to perform in JSON format
Example:β
[
{ "index": { "_index": "books", "_id": "book1" } },
{
"title": "The Great Gatsby",
"author": "F. Scott Fitzgerald",
"year": 1925
},
{ "delete": { "_index": "books", "_id": "book2" } },
{ "index": { "_index": "books", "_id": "book3" } },
{
"title": "Moby-Dick",
"author": "Herman Melville",
"year": 1851
},
{ "delete": { "_index": "books", "_id": "book4" } }
]
Count Documentsβ
This operation returns the number of matches for a search query. For more details, see the Elasticsearch count guide here.
Required Parameterβ
- Index: The name of the index to count documents in.
Optional Parameterβ
- Query: The query to filter documents in JSON format
Example:β
{
"query": {
"range": {
"timestamp": {
"gte": 1901
}
}
}
}
Check Document Existenceβ
This operation checks if a document exists in an index. For more details, see the Elasticsearch exists guide here.
Required Parameter:β
- Index: The name of the index to check for document existence
- Id: The ID of the document to check
Example:β
Index: books
Id: FJXTSZEBsuzUn2y4wZ-W
Multi Getβ
This operation retrieves multiple documents in a single request. For more details, see the Elasticsearch multi-get guide here.
Required Parameterβ
- Operations: The multi-get operations to perform in JSON format
Example:β
{
"docs": [
{ "_index": "books", "_id": "book124" },
{ "_index": "books", "_id": "book125" }
]
}
Scroll Searchβ
This operation retrieves large numbers of results from a single search request. For more details, see the Elasticsearch scroll guide here.
Required Parameterβ
- Scroll ID: The scroll ID for the search
- Scroll: The scroll time
Example:β
Scroll ID: DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAOWQWYm9vbDItY1NCOUExal9TcTBjeUEyZw
Scroll: 60m