Elastic Search
Elastic search is a distributed, RESTful search and analytics engine that is commonly used to index and search large volumes of data. In Illa, you can use the Elasticsearch data source to connect to Elasticsearch instances and perform queries and aggregations on your data.
Create Elastic Search
There are two ways to create a resource in Illa after signing into your Illa account.
- Create in Resources
Sign into your Illa account, select **Resources**
on the top of the page, and click **Create New**
button.
Select Elastic Search
from the database list.
Connect to the database with the required parameters described in Connection Settings
below.
Click **Test Connection**
to see if we can successfully connect to the database. If yes, click Save Resources
, else, double check the hostname, port, username, and password is correct.
After creating a resource, the ready Elastic Search will display as shown.
- Create in Builder
Sign into your Illa account, create a project in Illa Builder in the **App**
page, and navigate to the Action List
at the bottom of the page. Click **new**
, then select Elastic Search
from the database list. Then, connect to the database with required parameters described in Connection Settings
below.
Click **Test Connection**
to see if we can successfully connect to the database. If yes, click Save Resources
, else, double check the hostname, port, username, and password is correct.
Connection Settings
Here we need to provide information for connecting to Elastic Search database.
Properties | Required | Description |
---|---|---|
Name | required | The name for resource when creating actions in the ILLA. |
Hostname | required | The URL or IP address for your database |
Port | required | The server host's port number that you should use to connect. |
Database | required | The name of the database |
Username | required | the username you wish to use when logging in to the Elastic Search server. |
Password | required | Use this password for authentication. |
SSL options | optional | decides how high a secure SSL TCP/IP connection is prioritized while negotiating with the server. |
Create Actions
We have created an Elastic Search resource, we can add the action by selecting Elastic Search from action list and choosing the Create action
button.
Now we have added the Elastic Search server as an action to our building page.
Configure Elastic Search
Overview
Method Name | Description |
---|---|
Action Type | search, get a document, insert a document, update a document, delete a document |
Transformer | transforming data into the style you like using JavaScript |
insert a document
sending an HTTP PUT request to the Elasticsearch cluster with a JSON document that contains the data to be inserted.
Input
Properties | Required | Description |
---|---|---|
Body | optional | a JSON document that contains the data to be inserted |
Index | optional | name of the index where the document should be inserted |
For example, to insert value1
, value2
, and value3
into field1
, field2
, and field3
into our Elastic search database, put the code snippet below into the **Body
and insert2
for Index
**.
{
"field1": "value1",
"field2": "value2",
"field3": "value3"
}
Output
Success message of whether the document is inserted successfully and information of the inserted document.
Use {{insert.data}}
to get the message.
update a document
sending an HTTP POST
or PUT
request to the Elasticsearch cluster with the ID of the document that should be updated, and a JSON document that specifies the changes to be made.
Input
Properties | Required | Description |
---|---|---|
Body | optional | The new value to be assigned to the field. |
Index | optional | The name of the index where the document is stored. |
Id | optional | The unique identifier for the document. |
For example, to update value1
, value2
, and value3
for field1
, field2
, and field3
into our Elastic search database, put the code snippet below into the Body,
insert2
for Index
, and copy-paste the document Id
from the insert message.
{"doc":{
"field1": "value11",
"field2": "value2",
"field3": "value3"
}}
Output
Success message of whether the document is updated successfully and information of the updated document.
Use {{update.data}}
to get the message.
Search
query and retrieve documents from an index
Input
Properties | Required | Description |
---|---|---|
Query | optional | specify the search query that is used to match documents in an index |
Index | optional | specify the name of the index or indices that should be searched |
For example, to search the database to find documents with key-value pair "field1": "value1"
, put the code snippet below into the Query
.
{
"query": {
"match": {
"field1": "value1"
}
}
}
Output
Success message with the number of hits/documents it finds that matches the query and the info for every hit.
Use {{search.data}}
to get the message.
get a document
sending an HTTP GET
request to the Elasticsearch cluster with the ID of the document that should be retrieved.
Input
Properties | Required | Description |
---|---|---|
Index | optional | The name of the index where the document is stored. |
Id | optional | The unique identifier for the document. |
For example, to get the document info for the document we just updated, put insert2
for Index
, and copy-paste the document Id
from the updated message.
Output
returns the document with the specified ID, or a 404 Not Found
error if the document does not exist.
Use {{get.data}}
to get the message.
delete a document
sending an HTTP DELETE request to the Elasticsearch cluster with the ID of the document that should be deleted.
Input
Properties | Required | Description |
---|---|---|
Index | optional | The name of the index where the document is stored. |
Id | optional | The unique identifier for the document. |
For example, to delete document, put insert2
for Index
, and copy-paste the document Id
from the updated message.
Output
returns the document with the specified ID, or a 404 Not Found
error if the document does not exist.