API Reference / API Methods / Recommend / Get trending global items

Get Trending Global Items

Required API Key: any key with the search ACL
Method signature
$recommendClient->getTrendingGlobalItems(array requests)

About this method # A

Retrieve globally trending items.

Examples # A

1
2
3
4
5
6
7
8
9
10
11
12
client.getTrendingGlobalItems([
  {
    indexName: 'your_index_name',
    threshold: 80
  },
])
.then(({ results }) => {
  console.log(results);
})
.catch(err => {
  console.log(err);
});

Parameters # A

requests #
type: list of request object
Required

A list of request objects to execute.

requests âž” request object #

indexName #
type: string
Required

The name of the target index.

threshold #
type: number
Required

Threshold for the recommendations confidence score (between 0 and 100). Only recommendations with a greater score are returned.

maxRecommendations #
type: number

The number of recommendations to retrieve. Depending on the available recommendations and the other request parameters, the actual number of hits may be lower than that. If maxRecommendations isn’t provided or set to 0, all matching recommendations are returned, and no fallback request is performed.

queryParameters #
type: Omit<SearchParameters, 'page' | 'hitsPerPage' | 'offset' | 'length'>

List of search parameters to filter the recommendations.

fallbackParameters #
type: Omit<SearchParameters, 'page' | 'hitsPerPage' | 'offset' | 'length'>

List of search parameters to use as fallback when there are no recommendations.

Response # A

This section shows the JSON response returned by the API. Since each language encapsulates this response inside objects specific to that language and/or implementation, the actual type in your language might differ from what’s written here. You can view the response in the logs (using the getLogs method).

JSON format#

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{
  "results": [
    {
      "hits": [
        {
          "_highlightResult": {
            "category": {
              "matchLevel": "none",
              "matchedWords": [],
              "value": "Men - T-Shirts"
            },
            "image_link": {
              "matchLevel": "none",
              "matchedWords": [],
              "value": "https://example.org/image/D05927-8161-111-F01.jpg"
            },
            "name": {
              "matchLevel": "none",
              "matchedWords": [],
              "value": "Jirgi Half-Zip T-Shirt"
            }
          },
          "_score": 32.72,
          "category": "Men - T-Shirts",
          "image_link": "https://example.org/image/D05927-8161-111-F01.jpg",
          "name": "Jirgi Half-Zip T-Shirt",
          "objectID": "D05927-8161-111",
          "position": 105,
          "url": "men/t-shirts/d05927-8161-111"
        }
      ],
      "processingTimeMS": 1,
    }
  ]
}
results #
list of result

List of results in the order they were submitted, one per query.

{
  "results": [
    {
      "hits": [
        {
          ...,
          _score: 32.72
        }
      ],
    },
  ]
}

results âž” result #

The results object contains the same hits object as the one of the search method. Each result also includes the following additional field:

_score #
number

The confidence score of the recommended item, the closer it’s to 100, the more relevant.

Did you find this page helpful?
PHP v3