The Search Based Analytics API lets you:
- Develop applications to list query suggestions and retrieve the associated response from the query.
- Embed a Google Search-like interface to enable plain English requests to search across datasets within a given user's account.
Using Knowi's Search Analytics empowers your end-users the ability to ask questions of their data in English. Think of this as a Google search on your datasets. This functionality can be embedded in your application through Single Sign-On.
Similar to embedding with SSO and the Javascript API, the steps to embedding Search Analytics are almost identical and can be achieved in three steps:
1. User Token: Create a Knowi user token for a new or existing user
curl -i -X POST -d "user=email@domain.com&ssoCustomerToken=<SSO_TOKEN>" https://knowi.com/sso/user/create
2. Session Token: Create a Knowi session token with the user token from step 1
curl -i -X POST -d "user=email@domain.com&userToken=<USER_TOKEN>" https://knowi.com/sso/session/create
3. Embed: Write a Javascript file with the session token returned from step 2
Knowi.render('#knowi-div', {
type: 'nlp',
token: "ii7Cdf7QJy3PaYQLrdZLaGgMnq3Dy2Q1JEhiiuDR9GG64ie",
url: 'http://localhost:9090',
view: {
nlpOptions: {
icon: "off",
css: {
background: 'transparent',
width: '80%'
},
placeholder: "Try: total sales for canada this week",
help: "off",
helpText: "Ability to customize the help text of the question mark",
defaultView: "visual"
}
}
}, function () {
});
Note: For embedding Search Analytics, type
must be nlp
Following API's may be used to create your own search bar. Here are the relevant API calls:
GET: /sso/nlp/suggestions
Parameter | Required? | Description |
token | yes | SSO session token |
query | yes | Query to process |
Returns: - A list of suggestions as json array
POST: /sso/nlp/parse
Parameter | Required? | Description |
token | yes | SSO session token |
query | yes | Query to process |
datasetId | yes | Dataset ID that your query should point to |
format | no | Format of the response (json, txt). Defaults to json |
Returns: - Data as json or txt array