Focus on random search: afs:sort=random - AFS

AFS Integration Guide

Product
AFS
AFS_Version
7.7
Category
Reference Guide

This topic details the usage of the value random for the parameters afs:sort.

Random sort order ensures that different visitors do not get the same result order for a given query. However, for a given visitor and query, results are coherent. For example, while paging through the results, each document is only displayed once.

Also, the results of page 1 remain the same if the user selects page 2 and then goes back to page 1.

The consistency of results is guaranteed by a "seeding" integer parameter given to afs:random.

The seeding parameter can either:

  • Be chosen by the search application
  • Be set automatically by AFS (in this case the value changes every second)

The seeding parameter is a 32-bit positive integer.

If the search application chooses the seeding parameter (ensuring different visitors will receive different seeding parameters) then this parameter must be used in every AFS call as in the following example:

http://server/search?....&afs:sort=random(34858)

If the search application does not choose the seeding parameter then the first call to AFS for a visitor will not provide a seeding parameter:

http://server/search?....&afs:sort=random()

AFS automatically provides a value for the seeding parameter, this value is displayed in the output feed, in a similar way to other parameters:

<afs:replies ...>
<afs:header>
<afs:query ...>
<afs:queryParam name="afs:sort" value="random(1311325107)"/>

Subsequent calls to AFS for this visitor have to reuse the seeding parameter (1311325107 in the previous example).