<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/cts.max.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>cts.max</api:function-name><api:suggest>cts.max</api:suggest><api:suggest>cts</api:suggest><api:suggest>max</api:suggest><api:function-link mode="xquery" fullname="cts:max">/apidoc/8.0/cts:max.xml</api:function-link><api:function mode="javascript" name="max" type="builtin" lib="cts" category="SearchBuiltins" subcategory="Math Lexicon" hidden="false" bucket="MarkLogic Built-In Functions" prefix="cts" namespace="http://marklogic.com/cts" fullname="cts.max"><api:summary>
  Returns the maximal value given a value lexicon.
  This function performs the calculation in parallel in all data nodes then
  aggregates the values. It generally performs better than <code xmlns="http://www.w3.org/1999/xhtml">fn:max</code>,
  especially on large clusters.
</api:summary><api:params><api:param name="range-index" type="cts:reference"><api:param-description>
    Reference to a range index.
  </api:param-description><api:param-name>range-index</api:param-name><api:param-type>cts.reference</api:param-type></api:param><api:param name="options" type="xs:string*" optional="true"><api:param-description>
    Same as the "options" parameter in <code xmlns="http://www.w3.org/1999/xhtml">cts:aggregate</code>.
  </api:param-description><api:param-name>options</api:param-name><api:param-type>String[]</api:param-type></api:param><api:param name="query" type="cts:query?" optional="true"><api:param-description>
     Same as the "query" parameter in <code xmlns="http://www.w3.org/1999/xhtml">cts:aggregate</code>.
  </api:param-description><api:param-name>query</api:param-name><api:param-type>cts.query?</api:param-type></api:param><api:param name="forest-ids" type="xs:unsignedLong*" optional="true"><api:param-description>
     Same as the "forest-ids" parameter in <code xmlns="http://www.w3.org/1999/xhtml">cts:aggregate</code>.
  </api:param-description><api:param-name>forest-ids</api:param-name><api:param-type>String[]</api:param-type></api:param></api:params><api:return>xs.anyAtomicType?</api:return><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
//   This query assumes an element range index is configured
//   in the database for the 'Amount' element.

cts.max(cts.elementReference(xs.QName("Amount")));

=&gt; 162.9500000000000034
</pre></api:example></api:function></api:function-page>