VOOZH about

URL: https://www.cdata.com/kb/tech/elasticsearch-cloud-appsmith.rst

⇱ Create Elasticsearch-Connected Applications in Appsmith


Create Elasticsearch-Connected Applications in Appsmith

πŸ‘ Cameron Leblanc
Cameron Leblanc
Senior Technology Evangelist
Connect to Elasticsearch Data via CData Connect AI in Appsmith and create custom business applications with real-time access to Elasticsearch data.

Appsmith is an open-source internal tool builder that allows teams to quickly and easily build a UI to help improve their business operations. When combined with CData Connect AI, you gain immediate access to Elasticsearch data for business applications. This article outlines the process of connecting to Elasticsearch using Connect AI and creating a basic application from Elasticsearch data within Appsmith.

CData Connect AI offers a pure SQL Server, cloud-to-cloud interface for Elasticsearch, enabling the creation of business applications directly from live Elasticsearch data within Appsmith, all without the need for data replication to a native database. As you build applications, Appsmith generates SQL queries to gather data. With its inherent optimized data processing capabilities, CData Connect AI efficiently channels all supported SQL operations, including filters and JOINs, directly to Elasticsearch. This leverages server-side processing to swiftly deliver the requested Elasticsearch data.

About Elasticsearch Data Integration

Accessing and integrating live data from Elasticsearch has never been easier with CData. Customers rely on CData connectivity to:

  • Access both the SQL endpoints and REST endpoints, optimizing connectivity and offering more options when it comes to reading and writing Elasticsearch data.
  • Connect to virtually every Elasticsearch instance starting with v2.2 and Open Source Elasticsearch subscriptions.
  • Always receive a relevance score for the query results without explicitly requiring the SCORE() function, simplifying access from 3rd party tools and easily seeing how the query results rank in text relevance.
  • Search through multiple indices, relying on Elasticsearch to manage and process the query and results instead of the client machine.

Users frequently integrate Elasticsearch data with analytics tools such as Crystal Reports, Power BI, and Excel, and leverage our tools to enable a single, federated access layer to all of their data sources, including Elasticsearch.

For more information on CData's Elasticsearch solutions, check out our Knowledge Base article: CData Elasticsearch Driver Features & Differentiators.


Getting Started


Configure Elasticsearch Connectivity for Appsmith

Connectivity to Elasticsearch from Appsmith is made possible through CData Connect AI. To work with Elasticsearch data from Appsmith, we start by creating and configuring a Elasticsearch connection.

  1. Log into Connect AI, click Sources, and then click Add Connection
  2. πŸ‘ Adding a Connection
  3. Select "Elasticsearch" from the Add Connection panel
  4. πŸ‘ Selecting a data source
  5. Enter the necessary authentication properties to connect to Elasticsearch.

    Set the Server and Port connection properties to connect. To authenticate, set the User and Password properties, PKI (public key infrastructure) properties, or both. To use PKI, set the SSLClientCert, SSLClientCertType, SSLClientCertSubject, and SSLClientCertPassword properties.

    The data provider uses X-Pack Security for TLS/SSL and authentication. To connect over TLS/SSL, prefix the Server value with 'https://'. Note: TLS/SSL and client authentication must be enabled on X-Pack to use PKI.

    Once the data provider is connected, X-Pack will then perform user authentication and grant role permissions based on the realms you have configured.

    πŸ‘ Configuring a connection (Salesforce is shown)
  6. Click Save & Test
  7. Navigate to the Permissions tab in the Add Elasticsearch Connection page and update the User-based permissions. πŸ‘ Updating permissions

Add a Personal Access Token

When connecting to Connect AI through the REST API, the OData API, or the Virtual SQL Server, a Personal Access Token (PAT) is used to authenticate the connection to Connect AI. It is best practice to create a separate PAT for each service to maintain granularity of access.

  1. Click on the Gear icon () at the top right of the Connect AI app to open the settings page.
  2. On the Settings page, go to the Access Tokens section and click Create PAT.
  3. Give the PAT a name and click Create. πŸ‘ Creating a new PAT
  4. The personal access token is only visible at creation, so be sure to copy it and store it securely for future use.

With the connection configured and a PAT generated, we are ready to connect to Elasticsearch data from Appsmith.

Create an Appsmith Application from live Elasticsearch Data

To establish a connection from Appsmith to the CData Connect AI Virtual SQL Server, follow these steps:

Connect to Elasticsearch in Appsmith

  1. Log in to your Appsmith instance and create a new application.
  2. In the new application, open the Data page and select Bring your data. πŸ‘ Open the Data page
  3. On this page, you can search for Microsoft SQL Server and select it as your data source. πŸ‘ Select Microsoft SQL Server datasource
  4. Enter a name for the new data source and then enter the following connection settings:
  5. Click Test configuration to confirm a successful connection, then click Save to save the datasource.

Create a new query

With a connection configured to a datasource, we can add a SQL query to actually retrieve data from the data source.

  1. On the screen with the new data source, click New Query. πŸ‘ Create a New Query
  2. This opens the Query Editor to enter a SQL query to select data. To assist with specifying a SQL query, use the Explorer of CData Connect AI to preview the SQL queries and the data you want to retrieve. πŸ‘ Preview queries in the Explorer
  3. After creating the SQL query, return to the Query Editor in Appsmith and enter the SQL query, then click Run. πŸ‘ Run the SQL query
  4. Once the query successfully runs, all that remains is to set up the Page to display the data retrieved.

Display Elasticsearch data

  1. Open the UI tab and click New UI element. πŸ‘ New UI element
  2. Choose a new UI element to grab, then drag and place the element on the page. πŸ‘ New UI element
  3. Click Connect data on the new UI element, then select the query previously created. πŸ‘ Connect to data
  4. With the data connected, it is then displayed in the UI element. πŸ‘ UI element connected

Deploy the application

With the Elasticsearch data connected to the UI elements in the application, we can deploy the Application. To do this, click Deploy in the top-right corner of Appsmith, then the application is opened in a separate window displaying the Elasticsearch data.

πŸ‘ Application deployed

Get CData Connect AI

To get live data access to hundreds of SaaS, Big Data, and NoSQL sources directly from your cloud applications, try CData Connect AI today!