Loading TOC...


   $nodes as Array,
   [$options as Object?]
) as Object


Produces a set of clusters from an array of nodes. The nodes can be any set of nodes, and are typically the result of a cts.search operation.

$nodes The array of nodes to cluster.
$options An object representation of the options for defining the clustering parameters. The following is a sample options object:

{ labelMaxTerms: 4, maxClusters: 6, useDbConfig: true }

The cts.cluster options include:


An integer specifying how many hierarchical cluster levels the clusterer should return. The default is 1, which means no hierarchical clusters are returned.


An integer specifying the maximum number of terms to use in constructing a cluster label. The default is 3.


A single word or an array of words that are to be excluded from cluster label. The default is to not exclude any words.


A boolean that indicates whether attribute terms should be excluded from the cluster label. The default is to include terms from attributes.


A boolean that indicates whether additional details on the terms used in label generation are to be included in the output. See the documentation on cts:distinctive-terms for details on the format of the terms returned. The default false, meaning no such details are given.


An integer specifying a minimum number of desired clusters returned (at any hierarchical level). However, if no satisfactory clustering can be produced at a given level, only one cluster will be returned, regardless of this setting. The default is 3.


An integer specifying a maximum number of clusters that can be returned (at any hierarchical level). The default is 15.


A boolean indicating whether it is acceptable for nodes to be assigned to more than one cluster. The default is false.


An integer value specifying the maximum number of distinct terms to use in calculating the cluster. The default is 200. Increasing the value will increase the cost (in terms of both time and memory) of calculating the clusters, but may improve the quality of the clusters.


A value indicating which clustering algorithm to use, either k-means or lsi. The default is k-means. The LSI algorithm is significantly more expensive to compute, both in terms of time and space.


Specifies the number of times to run the clusterer against the specified data. The default is 1. Because of the way the algorithms work, running the cluster multiple times will increase the number of terms, and tends to improve the accuratacy of the clusters. It does so at the cost of performance, as each time it runs, it has to do more work.


A boolean value indicating whether to use the current DB configuration for determining which terms to use. The default is false, which means that the default set of options, as well as any indexing options you specify in the options node, will be used for calculating the clusters and their labels. When set to true, any indexing options set in the context database configuration (including any field settings) are used, as well as any default settings that you have not explicitly turned off in the options node.

The options object also includes indexing options in the http://marklogic.com/xdmp/database namespace. These control which terms to use. Note that the use of certain options, such as fastCaseSensitiveSearches, will not impact final results unless the term vector size is limited with the maxTerms option. Other options, such as phraseThroughs, will only generate terms if some other option is also enabled (in this case fastPhraseSearches).

The database options are the same as the database options shown for cts.distinctiveTerms.


        algorithm: "lsi",
        hierarchicalLevels: 3,
        minClusters: 2,
        maxClusters: 12,
        overlapping: false,
        labelIgnoreWords: ["of", "the", "on", "in", "at", "a", "an", "for", "from", "by", "and"],
        stemmedSearches: "advanced",
        fastPhraseSearches: true,
      "label":"neonate, cortisol, fetal",
      "label":"fetal, cortisol, being",
      "label":"locus, male, fetal",
      "label":"normal, endometrium, also",
      "label":"km, administration, do",


    Powered by MarkLogic Server 7.0-4.1 and rundmc | Terms of Use | Privacy Policy