Loading TOC...

MarkLogic 12 EA 1 Product Documentation
spell.makeDictionary

spell.makeDictionary(
   words as String[],
   [output-kind as String]
) as Item

Summary

Creates a dictionary node from a sequence of words.

Parameters
words The words from which to construct a dictionary.
output-kind The kind of the returned dictionary node. If "element", an xml element is returned; if "object", a javascript object is returned.

The default value is "object".

Example

  const spell = require("/MarkLogic/spell");

  const words = ["words", "to", "go", "in", "the", "dictionary"];
  spell.makeDictionary(words)

  => 
  {
    "words":[
      "words",
      "to",
      "go",
      "in",
      "the",
      "dictionary"
    ]
  }

  

Example

  const spell = require("/MarkLogic/spell");

  spell.makeDictionary(cts.words())

  => A javascript object containing all the words in the database.  
     Use spell.insert to insert this into the database as a dictionary.  
     This example requires a word lexicon on the database.  You can 
     construct the sequence of words any way you like.
  

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