Using Search to Insight

Search to Insight is a natural language query interface used to get quick insights about your data.

Note

In the same way as for a story, the interface can only identify and work with words in English.

Search to Insight displays query results for indexed live HANA data models and acquired data models that you have access to, or any dimensions that do not have Data Access Control or have granted Data Access Control to you.

In analytics designer, there are two Search to Insight modes:

  • Simple mode – this is designed for application users with little knowledge of the models behind Search to Insight who want to perform searches by simply asking questions.

  • Advanced mode – this is designed for application users who have some knowledge of the models and dimensions behind the data and want to switch models and select dimensions according to their needs when querying data.

Creating a Search to Insight

You need to create a Search to Insight before you can query data in it.

  1. In the Scripting section of the Outline, select right next to Search to Insights to create a Search to Insight.

    The side panel Search to Insight opens with a default name of the Search to Insight displayed. You can change the name at will.

  2. In Models to Search, select Add Model to add one or more models you want to query.

    Note

    Only models supported by Search to Insight can be added to the Search to Insight component. For live data models, only indexed live HANA data models are supported. Acquired data models don’t need to be indexed manually. Indexing is automatically triggered for acquired data models when you perform a query on the models for the first time.

  3. Click Done to finish creating the scripting object.

Related APIs

After adding the widget to the canvas or popup, as an application designer you can leverage the following APIs to open or close a Search to Insight dialog:

Code Syntax
//Display the Search to Insight dialog. If the dialog is already open, the query interface and modes will be updated. The mode parameter has two options: SearchToInsightDialogMode.Simple and SearchToInsightDialogMode.Advanced.
SearchToInsight_1.openDialog(question: string, mode: string, ?cleanHistory:boolean, ?autoSearch: boolean): void;

//Can be called by PostMessage API when a Search to Insight dialog is open to close the dialog
SearchToInsight_1.closeDialog(): void;

You can also apply search to insight results to a chart using applySearchToChart() API and leverage the following variable related APIs to save variable value in a Search To Insight component and apply to chart when calling applySearchToChart():

Code Syntax
//get model variable 
SearchToInsight_1.getVariables(modelId: string): VariableInfo[]

// set model variable
setVariableValue(modelId: string, variable: string|VariableInfo, variableValue: string|number|VariableValue|VariableValue[]): void 


// Search by input question within selected search to insight model and apply the results to a chart
SearchToInsight_1.applySearchToChart(question: string, chart: chart): boolean 

Example 1: Trigger Different Modes of Search to Insights

Example

In this example, you can design a simple application to let application users trigger different modes of Search to Insight for the questions they enter.

First, in addition to the scripting object SearchToInsight_1, add an input field (InputField_1), a button (Button_1) and a checkbox group (CheakboxGroup_1) to the Canvas as below:

Then write the following script for the button widget Button_1:

Sample Code
var mode = SearchToInsightDialogMode.Simple;
if (CheckboxGroup_1.getSelectedKeys().length !== 0)
{
      mode = SearchToInsightDialogMode.Advanced;
}
var inputText = InputField_1.getValue();
SearchToInsight_1.openDialog(inputText, mode, false, true);

Result: After you save the application and choose Run Analytic Application, application users can either trigger simple mode by entering a question and clicking the Search to Insight button, or trigger advanced mode by entering a question, selecting the Advanced mode, then clicking the Search to Insight button.

Example 2: Receive Question from Host HTML Page and Apply Search to Insight Results to a Chart

Example

In this example, you can build your own search to insight user interface and integrate search to insight results to your own portal.

First, embed your analytic application in your own portal via iFrame and maintain corresponding code to get the message users input in the portal and post it to the embedded analytic application.

Then go back to the analytic application, besides adding the scripting object SearchToInsight_1, write the following script for the onPostMessageReceived event of the application:

Sample Code
SearchToInsight_1.applySearchToChart(message, Chart_1);
Chart_1.setVisible(true);

Result: After that in your own portal, users can ask a question and see the chart of the embedded analytic application appear and display corresponding search to insight results.