Skip to main content

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.

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.

external_resource

Select Elastic Search from the database list.

action_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.

ela_ex_ready

  • 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.

ela_config

PropertiesRequiredDescription
NamerequiredThe name for resource when creating actions in the ILLA.
HostnamerequiredThe URL or IP address for your database
PortrequiredThe server host's port number that you should use to connect.
DatabaserequiredThe name of the database
Usernamerequiredthe username you wish to use when logging in to the Elastic Search server.
PasswordrequiredUse this password for authentication.
SSL optionsoptionaldecides 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.

ela_resource_list

Now we have added the Elastic Search server as an action to our building page.

ela

Overview

Method NameDescription
Action Typesearch, get a document, insert a document, update a document, delete a document
Transformertransforming 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

PropertiesRequiredDescription
Bodyoptionala JSON document that contains the data to be inserted
Indexoptionalname 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.

ela_insert_data

Use {{insert.data}} to get the message.

ela_insert_code

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

PropertiesRequiredDescription
BodyoptionalThe new value to be assigned to the field.
IndexoptionalThe name of the index where the document is stored.
IdoptionalThe 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.

ela_update_data

Use {{update.data}} to get the message.

ela_update_code

query and retrieve documents from an index

Input

PropertiesRequiredDescription
Queryoptionalspecify the search query that is used to match documents in an index
Indexoptionalspecify 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.

ela_search_data

Use {{search.data}} to get the message.

ela_search_code

get a document

sending an HTTP GET request to the Elasticsearch cluster with the ID of the document that should be retrieved.

Input

PropertiesRequiredDescription
IndexoptionalThe name of the index where the document is stored.
IdoptionalThe 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.

ela_get_data

Use {{get.data}} to get the message.

ela_get_code

delete a document

sending an HTTP DELETE request to the Elasticsearch cluster with the ID of the document that should be deleted.

Input

PropertiesRequiredDescription
IndexoptionalThe name of the index where the document is stored.
IdoptionalThe 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.

ela_delete_data