Spellchecking and Did You Mean

Users don’t always enter the correct or optimal search terms. Site Search can spellcheck the terms users enter and provide search results for corrected terms. It can also ask users whether they meant other, similar terms (Did You Mean).

You turn both Spellchecking and Did You Mean on or off.

With Spellchecking and Did You Mean enabled, when Site Search evaluates a query:

  • Spellchecking – If the query returns no results, but a similar query would return results, then Site Search presents the results for the similar query. For example:

    Spellchecking result

  • Did You Mean – If the query returns results, but a similar query would return more results, then Site Search presents the results for the original query, and presents the alternative query as a Did You Mean suggestion. In the UI or a Results modile, this is a link. Clicking the link submits the alternative query. For example:

    Did You Mean result

Turn Spellchecking and Did You Mean on or off

  1. In Page Builder, hover over the Results module, and then click Edit module.

  2. Select the Show Spellchecking checkbox to enable Spellchecking and Did You Mean. Unselect the checkbox to disable Spellchecking and Did You Mean.

Use Spellchecking and Did You Mean results in the Search API

In these examples, Spellchecking and Did You Mean are enabled in the Site Search app.

Site Search finds a spelling error

For some searches, Site Search will detect spelling errors.

This is the search:

curl -H 'X-API-Key: YOUR_API_KEY' 'https://subdomain.lucidworks.cloud/pathname/api/v1/search?q=fusiom'

If Site Search finds a spelling error in the submitted query, then the Search API returns results like these:

{
  "query" : {
    "target" : "",
    "filters" : [ ],
    "type" : "any",
    "fields" : "",
    "view" : "",
    "collection" : "",
    "autoCorrected" : false,
    "facts" : { },
    "transientParameters" : [ "fa" ],
    "val" : {
      "act" : "fusion",
      "dsp" : "fusiom"
    },
    "rpp" : 10,
    "facets-enabled" : true,
    "max" : -1,
    "page" : 1,
    "facets" : "",
    "sorts" : [ ],
    "custom" : { },
    "other" : { },
    "default" : false
  },
  "hits" : {
    "act" : [ "Long", 7168 ]

For "val" (the value of the query), notice "act" : "fusion" (the corrected term, for which results have been returned) and "dsp" : "fusiom" (the submitted term). At the bottom of this example, you see the actual number of results for the corrected query (7168).

Site Search finds results for the query and has a Did You Mean suggestion

For some searches, Site Search finds results for the query, but also has a Did You Mean suggestion.

This is the search:

curl -H 'X-API-Key: YOUR_API_KEY' 'https://subdomain.lucidworks.cloud/pathname/api/v1/search?q=upgraded'

If Site Search finds results for the submitted query, but also has a Did You Mean suggestion, then the Search API returns results like these:

{
  "query" : {
    "target" : "",
    "filters" : [ ],
    "type" : "any",
    "fields" : "",
    "view" : "",
    "collection" : "",
    "autoCorrected" : false,
    "facts" : { },
    "transientParameters" : [ "fa" ],
    "val" : "upgraded",
    "rpp" : 10,
    "facets-enabled" : true,
    "max" : -1,
    "page" : 1,
    "facets" : "",
    "sorts" : [ ],
    "custom" : { },
    "other" : { },
    "default" : false
  },
  "hits" : {
    "act" : [ "Long", 4 ]
  },

For "val" (the value of the query), notice "upgraded" (the actual term, for which results have been returned). At the bottom of this example, you see the actual number of results for the corrected query (4).

At the very end of the response, there are messages:

  "messages" : [ {
    "_type" : "query-sugg",
    "type" : "spelling",
    "count" : 0,
    "label" : "upgrades",
    "query" : "upgrades",
    "auto-corrected" : false
  } ]

Notice the "query-sugg" message that has "query" : "upgrades". This is the Did You Mean suggestion.

As is done in the Results module, you could provide a link that submits that term as the query.

Site Search finds no matching results for the query

For some searches, Site Search finds no matching results.

This is the search:

curl -H 'X-API-Key: YOUR_API_KEY' 'https://subdomain.lucidworks.cloud/pathname/api/v1/search?q=qyzxfgthshdai'

This is part of the response:

{
  "query" : {
    "target" : "",
    "filters" : [ ],
    "type" : "any",
    "fields" : "",
    "view" : "",
    "collection" : "",
    "autoCorrected" : false,
    "facts" : { },
    "transientParameters" : [ "fa" ],
    "val" : "qyzxfgthshdai",
    "rpp" : 10,
    "facets-enabled" : true,
    "max" : -1,
    "page" : 1,
    "facets" : "",
    "sorts" : [ ],
    "custom" : { },
    "other" : { },
    "default" : false
  },
  "hits" : {
    "act" : [ "Long", 0 ]
  },

Note that there is no spelling correction for the value "qyzxfgthshdai" and that there were no results ("hits").

In this case, there is no "query-sugg" message.