How to pass custom Elastic Search query in JSON format in Bold BI dashboard
Bold BI allows users to specify Elasticsearch queries in JSON format while loading the dashboard. This feature enables the visualization of filtered data based on the query passed. However, it’s important to note that custom queries cannot be passed in Elasticsearch live connection. Instead, this can be achieved through the Web API data source.
Steps to Pass Custom Query in JSON Format
-
For custom query support, a sample data source with a dashboard parameter is needed. Create the sample data source using the Elasticsearch connector. If there are any data sources in the dashboard, they can also be used for dashboard parameter creation.
-
After connecting/editing the data source, drag and drop any table and then click the dashboard parameter icon.
-
The dashboard parameter window will open. In this window, enter a name for the parameter, select Mode as “Literal”, Type as “String” and enter the Custom query in the Current value test box. Save the parameter.
Note: Here we have set the mark value as 80 in custom query
-
Save the data source.
-
Now, connect to the Elasticsearch server using the Web API connector.
-
Enter the server URL with index in the URL textbox and change the method type to “Post”.
-
Set the dashboard parameter in the raw body section. In the raw body section, enter the “@” character, dashboard parameters name suggestions will be shown.
-
Select the dashboard parameter created for the custom query.
-
Enter the authentication details and select mode as live connection.
-
Click Preview & Connect. The Elasticsearch server will now be connected.
-
The data is shown based on the given custom query.
-
Save the data source and drag and drop some widgets and assign values using the Web API data source.
-
Select preview.
-
Click the dashboard parameter icon in the preview window.
-
The dashboard parameter window will open, now change the custom query value and then click apply.
-
The data in widgets get filtered based on the given custom query in the dashboard parameter.