Creating a Natural Language Search

Add specific content to your model to query an NLP-enabled data source.

Implementation:

  1. Make sure you have configured a data source, and it's NLP-enabled.
  2. Switch to the Definition panel.
  3. 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.

  1. Add text to the Question Text to determine the button's caption.
  2. Add the question to the expression parser.
  3. Add another form to your model underneath the first one you added.
  4. Add a Data Source Grid question.
  5. 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.

  1. Add a Natural Language Results question to your first form. Leave the question's text blank.
  2. Double-click the question and switch to the Further Question Options tab.
  3. Enter the keyword of your second form in the Linked Question or Group Keyword field. and click Save Question.
  4. Add a Parameter Expression attribute to the result's question.
  5. Type the name SearchTerm in the Expression Name field.
  6. Switch to the Value field.
  7. Type the keyword that will contain your query string into its Attribute Expression field.
  8. Click OK to save the attribute.
  9. Test this works by opening your application in Insights - click and type a query into the field provided.
  10. 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.