Dev guideRecipesAPI ReferenceChangelog
Dev guideRecipesUser GuidesNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev guide

Hit count

Describes how to get the hit count with the total field.

A hit count is the number of matching content items that a query returns. Display the hit count in Optimizely Graph with the total field so users see a clear results summary at the top of a list, table, map, or any form of Search Engine Results Page (SERP).

By default, Optimizely Graph shows accurate hit counts until 10,000 results. When there are more, it shows a -1 to significantly improve the request times of queries. Client applications must check for -1 and display a message such as "more than 10,000 results" instead of rendering the literal value. In many cases, showing the hit count beyond 10,000 results is not needed.

Get accurate hit counts

Enable the optional Boolean argument all on the total field when you need an exact hit count above 10,000 results, for example on a results page that reports the precise number of matches.

If accurate hit counts are important, enable this by adding the optional input Boolean argument all to the total field. By default, omit this input argument and it is false. Setting all: true increases query time because Optimizely Graph counts every matching document instead of stopping at 10,000.

{
  Content {
    items {
      Name
      ContentType
    }
    total(all: true)
  }
}