Loading TOC...


   $uri as xs:string*,
   $word as xs:string,
   [$options as (element()|map:map)?]
) as xs:string*


Suggests a list of spellings for a word. Returns a sequence of the most likely spellings for the specified word.

uri The URIs of the dictionaries to use.
word The word for which you get spelling suggestions.
options Options with which to customize this operation. You can specify options as either an options XML element in the http://marklogic.com/xdmp/spell namespace, or as a map:map. The options names below are XML element localnames. When using a map, replace the hyphens with camel casing. For example, "an-option" becomes "anOption" when used as a map:map key. This function supports the following options:
Specifies the maximum number of suggestions to be returned. The default is 10.
Specifies a cut off threshold for suggestions having a distance less than the given number. The default is 100. When passing a map option, the name of the key is distanceThreshold.

Usage Notes

This function is a built-in function, so you need not import a library module to use it.

This function only provides suggestions to words that are less than 256 characters in length; words 256 characters or longer return no suggestions. Also, it removes any dictionary entries that are 256 characters or more, so it will never return a suggestion with greater than 256 characters.


xquery version "1.0-ml";
(: Returns a sequence of suggestions such as the following, from the
 : dictionary with URI "myDictionary.xml":
 : ("occasionally", "occasional", "occasion", "occasions", "occasion's",
 :  "occasioned", "optionally", "educationally", "irrationally")


xquery version "1.0-ml";
spell:suggest("spell.xml", "albetros")
(: Returns a sequence of suggestions such as the following, from the dictionary
 : with the URI "/dictionary.xml":
 : ("albatross", "abettors", "alders", "alters", "Albert's", "Elbert's",
 :  "allegros", "alder's", "Walters", "abettor's")


xquery version "1.0-ml";
spell:suggest("/dictionary.xml", "occasionally", 
  <options xmlns="http://marklogic.com/xdmp/spell">

(: Returns a sequence of suggestions such as: 
 :   ("occasionally", "occasional", "occasion", "occasions")


(: pass options using a map :)
xquery version "1.0-ml";
  "/my/dictionary.xml", "occasionally", 
  map:map() => map:with("distanceThreshold", 200)
            => map:with("maximum", 4)

(: Returns a sequence of suggestions such as the following from the dictionary
 : with the URI "/my/dictionary.xml":
 : ("occasionally", "occasional", "occasion", "occasions")

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.