<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/cts.elementAttributeRangeQuery.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>cts.elementAttributeRangeQuery</api:function-name><api:suggest>cts.elementattributerangequery</api:suggest><api:suggest>cts</api:suggest><api:suggest>elementattributerangequery</api:suggest><api:function-link mode="xquery" fullname="cts:element-attribute-range-query">/apidoc/8.0/cts:element-attribute-range-query.xml</api:function-link><api:function mode="javascript" name="elementAttributeRangeQuery" type="builtin" lib="cts" category="SearchBuiltins" subcategory="cts:query Constructors" hidden="false" bucket="MarkLogic Built-In Functions" prefix="cts" namespace="http://marklogic.com/cts" fullname="cts.elementAttributeRangeQuery"><api:summary>
  Returns a <code xmlns="http://www.w3.org/1999/xhtml">cts:query</code> matching element-attributes by name with a
  range-index entry equal to a given value.  Searches with the
  <code xmlns="http://www.w3.org/1999/xhtml">cts:element-attribute-range-query</code>
  constructor require an attribute range index on the specified QName(s);
  if there is no range index configured, then an exception is thrown.
</api:summary><api:params><api:param name="element-name" type="xs:QName*"><api:param-description>
    One or more element QNames to match.
    When multiple QNames are specified,
    the query matches if any QName matches.
  </api:param-description><api:param-name>element-name</api:param-name><api:param-type>xs.QName[]</api:param-type></api:param><api:param name="attribute-name" type="xs:QName*"><api:param-description>
    One or more attribute QNames to match.
    When multiple QNames are specified,
    the query matches if any QName matches.
  </api:param-description><api:param-name>attribute-name</api:param-name><api:param-type>xs.QName[]</api:param-type></api:param><api:param name="operator" type="xs:string"><api:param-description>
    A comparison operator.
    <p xmlns="http://www.w3.org/1999/xhtml">
      Operators include:</p>
      <blockquote xmlns="http://www.w3.org/1999/xhtml"><dl>
        <dt>"&lt;"</dt>
        <dd>Match range index values less than $value.</dd>
        <dt>"&lt;="</dt>
        <dd>Match range index values less than or equal to $value.</dd>
        <dt>"&gt;"</dt>
        <dd>Match range index values greater than $value.</dd>
        <dt>"&gt;="</dt>
        <dd>Match range index values greater than or equal to $value.</dd>
        <dt>"="</dt>
        <dd>Match range index values equal to $value.</dd>
        <dt>"!="</dt>
        <dd>Match range index values not equal to $value.</dd>
      </dl></blockquote>
  </api:param-description><api:param-name>operator</api:param-name><api:param-type>String</api:param-type></api:param><api:param name="value" type="xs:anyAtomicType*"><api:param-description>
    Some values to match.
    When multiple values are specified,
    the query matches if any value matches.
  </api:param-description><api:param-name>value</api:param-name><api:param-type>(String | Number | Boolean | null)[]</api:param-type></api:param><api:param name="options" type="xs:string*" optional="true"><api:param-description>
    Options to this query.  The default is ().
    <p xmlns="http://www.w3.org/1999/xhtml">
      Options include:</p>
      <blockquote xmlns="http://www.w3.org/1999/xhtml"><dl>
        <dt>"collation=<em>URI</em>"</dt>
        <dd>Use the range index with the collation specified by
        <em>URI</em>.  If not specified, then the default collation
        from the query is used. If a range index with the specified
        collation does not exist, an error is thrown.</dd>
        <dt>"cached"</dt>
        <dd>Cache the results of this query in the list cache.</dd>
        <dt>"uncached"</dt>
        <dd>Do not cache the results of this query in the list cache.</dd>
        <dt>"min-occurs=<em>number</em>"</dt>
        <dd>Specifies the minimum number of occurrences required. If
        fewer that this number of words occur, the fragment does not match.
        The default is 1.</dd>
        <dt>"max-occurs=<em>number</em>"</dt>
        <dd>Specifies the maximum number of occurrences required.  If
        more than this number of words occur, the fragment does not match.
        The default is unbounded.</dd>
        <dt>"score-function=<em>function</em>"</dt>
        <dd>Use the selected scoring function. The score function may be:
          <dl>
          <dt>linear</dt><dd>Use a linear function of the difference between the
          specified query value and the matching value in the index to calculate
          a score for this range query.</dd>
          <dt>reciprocal</dt><dd>Use a reciprocal function of the difference
          between the specified query value and the matching value in the
          index to calculate a score for this range query.</dd>
          <dt>zero</dt><dd>This range query does not contribute to the
          score. This is the default.</dd>
          </dl>
        </dd>
        <dt>"slope-factor=<em>number</em>"</dt>
        <dd>Apply the given number as a scaling factor to the slope of the
        scoring function. The default is 1.0.</dd>
        <dt>"synonym"</dt>
        <dd>Specifies that all of the terms in the $value parameter are
        considered synonyms for scoring purposes.  The result is that
        occurrences of more than one of the synonyms are scored as if
        there are more occurrences of the same term (as opposed to
        having a separate term that contributes to score). </dd>
      </dl></blockquote>
  </api:param-description><api:param-name>options</api:param-name><api:param-type>String[]</api:param-type></api:param><api:param name="weight" type="xs:double?" optional="true"><api:param-description>
    A weight for this query.  The default is 1.0.
  </api:param-description><api:param-name>weight</api:param-name><api:param-type>Number?</api:param-type></api:param></api:params><api:return>cts.elementAttributeRangeQuery</api:return><api:usage>
  <p xmlns="http://www.w3.org/1999/xhtml">If you want to constrain on a range of values, you can combine multiple
  <code>cts:element-attribute-range-query</code> constructors together
  with <code>cts:and-query</code> or other composable <code>cts:query</code>
  constructors.</p>
  <p xmlns="http://www.w3.org/1999/xhtml">If neither "cached" nor "uncached" is present, it specifies "cached".</p>
  <p xmlns="http://www.w3.org/1999/xhtml">
    Negative "min-occurs" or "max-occurs" values will be treated as 0 and
    non-integral values will be rounded down.  An error will be raised if
    the "min-occurs" value is greater than the "max-occurs" value.
  </p>
  <p xmlns="http://www.w3.org/1999/xhtml">"score-function=linear" means that values that are further away from
  the bounds will score higher. "score-function=reciprocal" means that values
  that are closer to the bounds will score higher. The functions are scaled
  appropriately for different types, so that in general the default slope factor
  will provide useful results. Using a slope factor greater than 1 gives distinct
  scores over a smaller range of values, and produces generally higher scores.
  Using a slope factor less than 1 gives distinct scores over a wider range of
  values, and produces generally lower scores.
  </p>
</api:usage><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
// create a document with test data 
declareUpdate();
xdmp.documentInsert("/attribute1.xml", xdmp.unquote(
'&lt;root&gt;\n\
  &lt;entry sku="100"&gt;\n\
    &lt;product&gt;apple&lt;/product&gt;\n\
  &lt;/entry&gt;\n\
&lt;/root&gt;').next().value) ;
xdmp.documentInsert("/attribute2.xml", xdmp.unquote(
'&lt;root&gt;\n\
  &lt;entry sku="200"&gt;\n\
    &lt;product&gt;orange&lt;/product&gt;\n\
  &lt;/entry&gt;\n\
&lt;/root&gt;').next().value) ;
xdmp.documentInsert("/attribute3.xml", xdmp.unquote(
'&lt;root&gt;\n\
  &lt;entry sku="1000"&gt;\n\
    &lt;product&gt;electric car&lt;/product&gt;\n\
  &lt;/entry&gt;\n\
&lt;/root&gt;').next().value) ;

******
//   requires an attribute (range) index of
//   type xs:int on the "sku" attribute of
//   the "entry" element

cts.search(
  cts.elementAttributeRangeQuery(
      xs.QName("entry"), xs:QName("sku"), "&gt;=",
      500));

//  returns the following document (with URI "/attribute3.xml"):
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;root&gt;
  &lt;entry sku="1000"&gt;
    &lt;product&gt;electric car&lt;/product&gt;
  &lt;/entry&gt;
&lt;/root&gt;

</pre>
</api:example></api:function></api:function-page>