Area: Episerver Find
Applies to versions: 12 and higher
Other versions:

Search statistics

This topic describes the autocomplete, spelling suggestion, and related queries functionality provided by the Search Statistics component of the Episerver Find API. 

How it works

Search statistics provide an HTTP API for tracking searches and collecting statistical data about them. The aggregated statistics expose functionality you can use to enhance the search: autocomplete, spelling suggestions, and related queries.

Although you can interact with the Search Statistics API using any programming language that makes HTTP requests, API usage is typically done via JavaScript.


To gather search statistics for later analysis, use the Track() method in the search query:

    .Filter(f => f.MatchType(typeof(FashionProduct)))

See Tracking for more information.


After adding some autocomplete text in Find Manage > Optimization > Autocomplete. The autocomplete feature will be allowed on search textbox in Front-end. For adding this feature, a jQuery example is below need be added to page.

<script language="javascript">
$(function () {
            source: function (request, response) {
                    url: "@Model.PublicProxyPath" + "/_autocomplete?prefix=" + encodeURIComponent(request.term) + "&size=5" + "&tags="+encodeURIComponent("@Model.Tags"),
                    success: function (data) {
                        response($.map(data.hits, function (item) {
                            return {
                                label: item.query,
                                value: item.query
            minLength: 2

And add txtSearch to search form:

<input id="txtSeach" type="text" tabindex="1" name="q"/>


Based on what other users searched for, Search Statistics can provide spellchecks, popular queries similar to the one passed to the spellchecker. A jQuery example is below.

<script type="text/javascript">
$.get('/find_v2/_spellcheck?query=camonix?size=1', function (data) {
    $.each(data.hits, function(index, value)
        $('#spellcheck').append("<p>"+"Spellcheck for 'camonix': <a href=/Search/?q=" + value.suggestion + ">" + value.suggestion + "</a></p>");
<div id="spellcheck"></div>

The spellchecker accepts these parameters:
  • query (mandatory): the query to return spellchecks for.
  • size (optional): the number of spellchecks to return.

Related queries

Sometimes, it is valuable to discover relationships, for example people who search for a also search for b. Search Statistics calls this related queries. You can request them with the following jQuery.

<script type="text/javascript">
$.get('/find_v2/_didyoumean?query=chamoni&size=1', function (data) {
$.each(data.hits, function(index, value)
        $('#didyoumean').append("<p>"+"Didyoumean for 'chamonix': <a href=/Search/?q=" + value.suggestion + ">" + value.suggestion + "</a></p>");
<div id="didyoumean"></div>

Related queries accept these parameters:
  • query (mandatory): the query for which to return related queries.
  • size (optional): the number of related queries to return.

Related topic

Last updated: Oct 31, 2016