cts:cluster( $nodes as node()*, [$options as (element()|map:map)?] ) as element(cts:clustering)
Produces a set of clusters from a sequence
of nodes. The nodes can be
any set of nodes, and are typically the result of a
cts:search
operation.
Parameters | |
---|---|
$nodes | The sequence of nodes to cluster. |
options |
An XML
representation of the options
for defining the clustering parameters.
The options node must be in the
cts:cluster namespace.
The following is a sample options node:
The
The options element
also includes indexing
options in the The database options are the same as the database options shown for
|
cts:cluster( cts:search(//MILITARY, cts:word-query("apache"))[1 to 100], <options xmlns="cts:cluster" xmlns:db="http://marklogic.com/xdmp/database"> <hierarchical-levels>2</hierarchical-levels> <overlapping>false</overlapping> <label-max-terms>3</label-max-terms> <max-clusters>100</max-clusters> <label-ignore-words>of the on in at a an for from by and</label-ignore-words> <db:stemmed-searches>advanced</db:stemmed-searches> <db:fast-phrase-searches>true</db:fast-phrase-searches> <db:fast-element-word-searches>true</db:fast-element-word-searches> <db:fast-element-phrase-searches>true</db:fast-element-phrase-searches> </options>) ==> <clustering xmlns="http://marklogic.com/cts"> <cluster id="123456" label="apache helicopters" count="7" nodes="3 34 31 98 34 23 39"/> <cluster id="374632" label="apache linux" count="6" nodes="1 378 56 23 93 6"/> <cluster id="3452231" label="navajo codetalkers" count="8" nodes="44 87 32 77 50 12 13 15"/> ... <cluster id="2234" parent-id="123456" label="AH-64" count="2" nodes="3 39"/> <cluster id="34321" parent-id="123456" label="air force" count="5" nodes="34 31 98 34 23"/> <cluster id="34523" parent-id="374632" label="HTTP" count="3" nodes="1 56 23"/> <cluster id="968" parent-id="374632" label="LAMP" count="3" nodes="378 93 6"/> <options xmlns="cts:cluster" xmlns:db="http://marklogic.com/xdmp/database"> <algorithm>k-means</algorithm> <db:stemmed-searches>advanced</db:stemmed-searches> <db:fast-element-word-searches>true</db:fast-element-word-searches> <db:fast-element-phrase-searches>true</db:fast-element-phrase-searches> <db:language>en</db:language> <max-clusters>100</max-clusters> <min-clusters>2</min-clusters> <hierarchical-levels>2</hierarchical-levels> <initialization>smart</initialization> <label-max-terms>3</label-max-terms> <num-tries>1</num-tries> <score>logtfidf</score> <use-db-config>false</use-db-config> </options> </clustering>
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.