I used magical powers to guess the internals of the SmartTarget Query Tag to get a code example of how to query SmartTarget using the API. You can set a MaxItems attribute on the tag, which I see translates through to a fh_view_size parameter in the query string to Fredhopper. I notice that when this parameter is set, Fredhopper returns an items collection in the ResultSet object, with as many items in it as the max specified, and an itemsTotalCount property set to match the size of this collection.

These items however do not seem to correspond to the actual items returned in the promotions property in the ResultSet, and indeed the number of items in the promotions remains unaffected by the max that I specify. So if the promotions return 3 results, even if I specifiy a max of 2, I still get three back, and these three do not necessarily correspond to the 2 items returned in the items property.

Furthermore, if I don't specify a max, I get 10 items in the items property, and an itemsTotalCount of 32 (which seems to be the total number of promotional items I have published to the corresponding publication/target)

This is all pretty confusing, can anyone explain what these items/itemsTotalCount properties in the result set is for, and what they actually mean? Is there a way to get the actual number of promotional items filtered to a max value?

1 Answer 1


They are used for paging of search results, which are indeed completely separate from items returned by Promotions. The default of 10 is configurable within the Business Manager.

You can specify the max items to allow within a region, but this limit is enforced by the tags/controls. You can also specify a maximum number of items to return per Promotion and this limit is enforced by Fredhopper (i.e. it is applied in the results of the query already).

As for how to query using the API, you should have a look at the new QueryBuilder class in the API. I think it's a lot easier to use.

  • Thanks Peter; so if I understand it correctly, the query tag is performing two functions - finding matching promotions and executing a search query? Is this not a bit inefficient, if I do not care about the search query?
    – Will Price
    Commented Jul 9, 2015 at 12:39
  • Perhaps, but Fredhopper always returns both parts so there isn't really a choice there. If your query is specific enough, though, the result will only contain Promotions anyway. Commented Jul 9, 2015 at 12:45
  • Ah I see. Currently my query is very simple (specifies region only), so probably thats why I see all the items coming back
    – Will Price
    Commented Jul 9, 2015 at 12:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.