Popular Searches API
SearchStax Site Search solution’s Popular Searches API retrieves the most Popular Searches recorded by the Search App during the previous 30 days.
This page describes how to retrieve a Json document of popular-search strings for display on your search page.
The API can be accessed through any tool that assembles HTTP requests and dispatch them to a server. Among these would be the Python coreapi package, the Postman tool, and cURL. For Windows, use PowerShell 7.
Symbols enclosed in carets (< and >) such as <username> are metavariables. Substitute your local values when you encounter them in the examples.
Popular Search
This method returns a list of Popular Searches from a Search App. The pool of searches covers the most recent 30 days of search history.
GET <popular-searches-URL>?language=<code>&page=<n>&num_results=<n>
where <popular-searches-URL> is an endpoint from the Discovery API Tab of the App Settings screen. Language is an optional two-letter language code. Page is an optional page within the paginated result set. Num_results is an optional limit on the number of searches desired (1 through 20).
This method uses Discovery API Key authorization. The Discovery API key is displayed on the Discovery API Tab. It must be passed in the header of the request.
When invoked from Linux (Bash shell):
curl 'https://app.searchstax.com/api/v1/nn/popular-search/?language=en&num_results=10' -H 'Authorization: f17e2131927b055383669327b1dc95338a7bdd7d'
The response is a JSON document containing a list of popular searches.
{
"responseHeader": {
"zkConnected": true,
"status": 0,
"QTime": 1
},
"response": {
"numFound": 4,
"start": 0,
"numFoundExact": true,
"docs": [
{
"query": "drupal integration",
"count": 12
},
{
"query": "solr",
"count": 3
},
{
"query": "sitecore",
"count": 2
},
{
"query": "test",
"count": 2
}
]
}
}
The fields of each popular search have the following meanings:
- query: The text of a popular search.
- count: How many time the Search App has encountered this search.
The other fields are Solr internal values.
Questions?
Do not hesitate to contact the SearchStax Support Desk.