Creating a Natural Language Search
Add specific content to your model to query an NLP-enabled data source.
Implementation:
- Make sure you have configured a data source, and it's NLP-enabled.
- Switch to the Definition panel.
- Add a form to your model, and give it a Natural Language Input question. The question will render a text box for the end user to supply a query, and a button to execute that query.
Any other input question can be used as long as it's added to the expression parser. Choosing this option you'll have to manually add a button, or opt for another method of triggering a postback, since it's the postback that causes the query to run.
If the input question's type is compatible with the Auto Postback to Web Server option - such as multiple choice - you can use this instead of a button or other manual method.
- Add text to the Question Text to determine the button's caption.
- Add the question to the expression parser.
- Add another form to your model underneath the first one you added.
- Add a Data Source Grid question.
- Connect the grid to your NLP-enabled data source, Configure it and Save as normal.
Do not add more content to this form as it will not be rendered as part of your query results. Also do not apply a standard Data Source Filter to the grid as it will also be ignored.
- Add a Natural Language Results question to your first form. Leave the question's text blank.
- Double-click the question and switch to the Further Question Options tab.
- Enter the keyword of your second form in the Linked Question or Group Keyword field. and click Save Question.
- Add a Parameter Expression attribute to the result's question.
- Type the name SearchTerm in the Expression Name field.
- Switch to the Value field.
- Type the keyword that will contain your query string into its Attribute Expression field.
- Click OK to save the attribute.
- Test this works by opening your application in Insights - click and type a query into the field provided.
- Click the Search button to trigger a postback, and view the results.
If you specified any Sort or Filter conditions when you defined your data's NLP entity, these will be applied to the results. Otherwise, the grid's contents will match the order of rows in the source table.
Certain queries will override the data's standard sorting policy. For example, if you search for "widest products" and the data has an expression that recognises width, the resulting grid will attempt to display products in descending width order.