Smart Answers API


The SearchStax Site Search solution’s Smart Answers API offers AI-powered question-answering capabilities integrated with Apache Solr for document retrieval. This service generates contextual answers to user queries by leveraging stored documents and AI processing.

GET <Smart Answers Endpoint>?q=<question> 

Authentication

This method requires Token authentication using a Read-Only token from the Search & Indexing tab of the App Settings > All APIs screen.

Query Parameters

The query string accepts the following parameters:

ParameterDescription
q
required
string
The user’s question
ignore_cache
optional
boolean
True or False, used to bypass cached answers.
<additional parameters>
optional
Any additional parameters that are normally used by the Search API, like start, spellcheck, language, model, etc.

Endpoints

The Smart Answers API uses three distinct endpoints depending on what kind of output you prefer:

  • Smart Answers Endpoint: Returns a data stream for real-time display on your search page. This endpoint is located on the Site Search > App Settings > All APIs > Search & Indexing screen.
  • JSON Endpoint: Append /json to the Smart Answers Endpoint to obtain the Smart Answers response as a JSON document.
  • XML Endpoint: Append /xml to the Smart Answers Endpoint to obtain the Smart Answers response as an XML document.

The JSON and XML endpoints return the full response at once, rather than streaming it. The endpoints are available only through the Smart Answers API.

Streaming Endpoint

The default endpoint returns a streaming response with media type text/event-stream.

  • If the query is a question, the stream returns I_AM_A_QUESTION followed by the answer.
  • If the query is not a question, the stream returns I_AM_NOT_A_QUESTION

Example

This is a cURL example as sent from a Bash or PowerShell command line:

curl -X GET \
  "https://search-ai-us.searchstax.com/api/v1/1234/answer/?q=What%20is%20solr&language=en&ignore_cache=true" \
  -H "authorization: Token <READ-ONLY_TOKEN>" \
  -H "Accept: text/event-stream"

The method returns a stream for real-time display on your search webpage. It looks like this is a Bash or PowerShell command window:

JSON Endpoint

This is a cURL example as sent from a Bash or PowerShell command line:

curl 'https://search-ai-us-east.searchstax.com/api/v1/1234/answer/json/?q=what%20is%20site%20search&model=Main%20Profile&language=en' \
 -H 'accept: text/json' \
 -H 'authorization: Token <READ-ONLY_TOKEN>'

The JSON endpoint returns a structured response with the following format:

{
 "success": true,
 "question": "what is site search?",
 "answer": "Site search refers to the functionality integrated into websites...",
 "processing_time": 16.48,
 "error_message": "Optional - only if there is an error"
}

XML Endpoint

The following example shows how to call the XML endpoint:

curl 'https://search-ai-us-east.searchstax.com/api/v1/1234/answer/xml/?q=what%20is%20site%20search&model=Main%20Profile&language=en' \
  -H 'accept: text/xml' \
  -H 'authorization: Token <READ-ONLY_TOKEN>'

The XML endpoint returns a structured response with the following format:

<SmartAnswer>
  <success>true</success>
  <question>what is site search??</question>
  <answer>**Site search** refers to the functionality integrated into websites...</answer>
  <processing_time>0.0018157958984375</processing_time>
</SmartAnswer>

Questions?

Do not hesitate to contact the SearchStax Support Desk.