Recommendations

The recommendations action returns related content for a given URL. A typical use case is to show similar content to a visitor (e.g. pages, products, blog posts) as an invitation to stay and discover more.

As Pandosearch is continually updating collections based on actual data, the recommendations returned will also automatically update if new content has been found that relates to the content on a given page.

Please note that recommendations are disabled by default. The API endpoint can be enabled as an add-on. Please contact support for more information on pricing and availability.

Request

To retrieve recommendations from Pandosearch, make a GET request to the following URL:

https://public.pandosearch.com/:collection/recommendations

All possible parameters need to be provided as query parameters.

In the rest of this page, the full URL and collection name are omitted for readability.

Parameter: id

Use a document URL as id query parameter to retrieve recommendations.

The following call will return recommendations for "https://enrise.com/services/pandosearch/":

recommendations?id=https%3A%2F%2Fenrise.com%2Fservices%2Fpandosearch%2F

As shown in the example, the id value needs to be URL encoded.

Parameter: size

To control the number of recommendations returned, use the size query parameter. The size parameter expects an integer and defaults to 5.

Example: the following call will return 8 recommendations for "https://enrise.com/":

recommendations?id=https%3A%2F%2Fenrise.com%2F&size=8

Parameter: track

In Pandosearch, all API requests are automatically tracked. We do not track any personal information – only information about the query sent and the results returned.

Tracking can be turned off by using the track parameter. If track=false is passed, the result won't be tracked or included in usage reports. In all other cases, the result will be tracked and included in usage reports.

An example use case is internal testing. You usually don't want your test requests to pollute your search usage analytics. To achieve this, you can use the track parameter as follows:

recommendations?id=https%3A%2F%2Fenrise.com%2F&track=false

Response

A recommendations response is a JSON document with the following structure:

{
  "total": 49,
  "hits": [
    {
      "type": "page",
      "url": "https://www.enrise.com/services/big-data/",
      "fields": {
        "title": "Big data",
        "description": "You've got the data, we know how to handle it."
      }
    },
    {
      "type": "page",
      "url": "https://www.enrise.com/services/custom-apis/",
      "fields": {
        "title": "Custom APIs",
        "description": "We build any API you need."
      }
    },
    {
      "type": "page",
      "url": "https://www.enrise.com/services/website-analysis/",
      "fields": {
        "title": "Website analysis",
        "description": "Quickly discover strengths and weaknesses and how to improve."
      }
    },
    {
      "type": "blog",
      "url": "https://www.enrise.com/blog/new-pandosearch-recommendations/",
      "fields": {
        "title": "New: Pandosearch recommendations",
        "description": "Engage with your vistors by showing them related content."
      }
    },
    {
      "type": "blog",
      "url": "https://www.enrise.com/blog/search-as-a-service/",
      "fields": {
        "title": "Search as a Service",
        "description": "Keep your website as it is. Vastly improve your visitors' search experience."
      }
    }
  ],
  "request": {
    "id": "https://enrise.com/services/pandosearch/",
    "size": 5,
    "track": true
  },
  "received": {
    "id": "https://enrise.com/services/pandosearch/"
  },
  "timing": {
    "search": 19.65,
    "search:took": 18,
    "request": 21.29
  }
}

The following sections provide detailed information for each response data part.

Data: hits

The hits property contains the recommendations found in the index. It is represented as array of objects. Each object looks as follows:

{
  "type": "blog",
  "url": "https://www.enrise.com/blog/search-as-a-service/",
  "fields": {
    "title": "Search as a Service",
    "description": "Keep your website as it is. Vastly improve your visitors' search experience."
  }
}

Each property explained in more detail:

  • type – the type of document. Available document types are specific for every implementation.
  • url - the URL where the document can be found. Use this value when showing a hyperlink to visitors.
  • fields – an object containing document data to display to visitors. This can be a title, body text, an image URL, or any other value known to Pandosearch. The exact fields returned are configured specifically for each implementation.

Data: request

This is an object containing the full request object with which a request was performed in our API. It contains all query string parameters you provided and all default settings for other parameters.

Data: received

This is an object containing only the sanitized query string parameters you provided.

Data: timing

The timing object contains all information about the time your request took. It is divided into:

  • search:took – Total amount of time spent by Elasticsearch in ms.
  • search – Total amount of time between sending the request to Elasticsearch and the receiving a back from Elasticsearch in ms (this is basically search:took + network overhead).
  • request – Total amount of time between the request coming in and sending the response out in ms.