This content is archived. See latest version here

Last updated: Apr 03 2014

Introduction

EPiServer Find Search Statistics provides additional tracking and statistics functionality for the EPiServer Find search solution.

Overview

Search Statistics provides an HTTP API for tracking searches made and getting statistical data for searches made. Based on the aggregated statistics it also exposes a number of functionalities that can be used to enhance the search functionality: autocomplete, spelling suggestions and related queries.

Search statistics

Although it is possible to interact with the Search Statistics API using any programming language that can make HTTP requests, usage of the API is typically done from JavaScript. Note that you must enable statistics for your index by clicking the add stats link under index details.

Tracking

To be able to gather statistics so that it later can be analyzed you need to use the method Track() in the search query:

C#
SearchClient.Instance.Search<IContent>()
  .For("banana")
  .Track()
  .GetResult();

Autocomplete

Search Statistics supports returning autocomplete suggestions by returning previous queries filtered on a prefix. A simple jQuery-example is shown below:

C#
<script type="text/javascript">
$.get('/en/find/rest/autocomplete/get/c?size=3', function (data) {
    $.each(data.Hits, function(index, value)
    {
        $('#autocomplete').append("<p>"+"Autocomplete for 'c': <a href=/Search/?q=" + value.Query + ">" + value.Query + "</a></p>");
    }
    )}, "jsonp");
</script>

<div id="autocomplete"></div>

Autocomplete accepts the following parameters:

  • prefix (mandatory): the prefix to filter all returned query suggestions.
  • size (optional): the number of autocomplete suggestions to return.

Spellchecking

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

C#
<script type="text/javascript">
$.get('/en/find/rest/spellcheck/get/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>");
    }
    )}, "jsonp");
</script>

<div id="spellcheck"></div>

The spellchecker accepts the following parameters:

  • query (mandatory): the query to return spellchecks for.
  • size (optional): the number of spellchecks to return.

Related queries

Sometimes it is of great value to find out relations like people who search for a also searched for b.Search Statistics calls this related queries and they can be requested as shown below using jQuery:

C#
<script type="text/javascript">
$.get('/en/find/rest/didyoumean/get/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>");
    }
    )}, "jsonp");
</script>

<div id="didyoumean"></div>

Related queries accepts the following parameters:

  • query (mandatory): the query to return related queries for.
  • size (optional): the number of related queries to return.

Do you have feedback on this documentation? Send an email to documentation@episerver.com. For development-related questions and discussions, refer to our Forums on https://world.episerver.com/forum/