<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/cts.elementValueQuery.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>cts.elementValueQuery</api:function-name><api:suggest>cts.elementvaluequery</api:suggest><api:suggest>cts</api:suggest><api:suggest>elementvaluequery</api:suggest><api:function-link mode="xquery" fullname="cts:element-value-query">/apidoc/8.0/cts:element-value-query.xml</api:function-link><api:function mode="javascript" name="elementValueQuery" 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.elementValueQuery"><api:summary>
  Returns a query matching elements by name with text content equal a
  given phrase.  <code xmlns="http://www.w3.org/1999/xhtml">cts:element-value-query</code> only matches against
  simple elements (that is, elements that contain only text and have no element
  children).
</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="text" type="xs:string*" optional="true"><api:param-description>
    One or more element values to match.
    When multiple strings are specified,
    the query matches if any string matches.
  </api:param-description><api:param-name>text</api:param-name><api:param-type>String[]</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>"case-sensitive"</dt>
        <dd>A case-sensitive query.</dd>
        <dt>"case-insensitive"</dt>
        <dd>A case-insensitive query.</dd>
        <dt>"diacritic-sensitive"</dt>
        <dd>A diacritic-sensitive query.</dd>
        <dt>"diacritic-insensitive"</dt>
        <dd>A diacritic-insensitive query.</dd>
        <dt>"punctuation-sensitive"</dt>
        <dd>A punctuation-sensitive query.</dd>
        <dt>"punctuation-insensitive"</dt>
        <dd>A punctuation-insensitive query.</dd>
        <dt>"whitespace-sensitive"</dt>
        <dd>A whitespace-sensitive query.</dd>
        <dt>"whitespace-insensitive"</dt>
        <dd>A whitespace-insensitive query.</dd>
        <dt>"stemmed"</dt>
        <dd>A stemmed query.</dd>
        <dt>"unstemmed"</dt>
        <dd>An unstemmed query.</dd>
        <dt>"wildcarded"</dt>
        <dd>A wildcarded query.</dd>
        <dt>"unwildcarded"</dt>
        <dd>An unwildcarded query.</dd>
        <dt>"exact"</dt>
        <dd>An exact match query. Shorthand for "case-sensitive",
        "diacritic-sensitive", "punctuation-sensitive",
        "whitespace-sensitive", "unstemmed", and "unwildcarded".
        </dd>
        <dt>"lang=<em>iso639code</em>"</dt>
        <dd>Specifies the language of the query. The <em>iso639code</em>
            code portion is case-insensitive, and uses the languages
            specified by
           <a href="http://www.loc.gov/standards/iso639-2/php/code_list.php" target="_blank">ISO 639</a>.
            The default is specified in the database configuration.</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>"synonym"</dt>
        <dd>Specifies that all of the terms in the $text 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.
    Higher weights move search results up in the relevance
    order.  The default is 1.0. The
    weight should be between 64 and -16.
    Weights greater than 64 will have the same effect as a
    weight of 64.
    Weights less than the absolute value of 0.0625 (between -0.0625 and
    0.0625) are rounded to 0, which means that they do not contribute to the
    score.
  </api:param-description><api:param-name>weight</api:param-name><api:param-type>Number?</api:param-type></api:param></api:params><api:return>cts.elementValueQuery</api:return><api:usage>
  <p xmlns="http://www.w3.org/1999/xhtml">
    If neither "case-sensitive" nor "case-insensitive"
    is present, $text is used to determine case sensitivity.
    If $text contains no uppercase, it specifies "case-insensitive".
    If $text contains uppercase, it specifies "case-sensitive".
  </p>
  <p xmlns="http://www.w3.org/1999/xhtml">
    If neither "diacritic-sensitive" nor "diacritic-insensitive"
    is present, $text is used to determine diacritic sensitivity.
    If $text contains no diacritics, it specifies "diacritic-insensitive".
    If $text contains diacritics, it specifies "diacritic-sensitive".
  </p>
  <p xmlns="http://www.w3.org/1999/xhtml">
    If neither "punctuation-sensitive" nor "punctuation-insensitive"
    is present, $text is used to determine punctuation sensitivity.
    If $text contains no punctuation, it specifies "punctuation-insensitive".
    If $text contains punctuation, it specifies "punctuation-sensitive".
  </p>
  <p xmlns="http://www.w3.org/1999/xhtml">
    If neither "whitespace-sensitive" nor "whitespace-insensitive"
    is present, the query is "whitespace-insensitive".
  </p>
  <p xmlns="http://www.w3.org/1999/xhtml">
    If neither "wildcarded" nor "unwildcarded"
    is present, the database configuration and $text determine wildcarding.
    If the database has any wildcard indexes enabled ("three character
    searches", "two character searches", "one character searches",  or
    "trailing wildcard searches") and if $text contains either of the
    wildcard characters '?' or '*', it specifies "wildcarded".
    Otherwise it specifies "unwildcarded".
  </p>
  <p xmlns="http://www.w3.org/1999/xhtml">
    If neither "stemmed" nor "unstemmed"
    is present, the database configuration determines stemming.
    If the database has "stemmed searches" enabled, it specifies "stemmed".
    Otherwise it specifies "unstemmed".
    If the query is a wildcarded query and also a phrase query
    (contains two or more terms), the wildcard terms in the query
    are unstemmed.
  </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"> Note that the text content for the value in a
  <code>cts:element-value-query</code> is treated the same as a phrase in a
  <code>cts:word-query</code>, where the phrase is the element value.
  Therefore, any wildcard and/or stemming rules are treated like a phrase.
  For example, if you have an element value of "hello friend" with wildcarding
  enabled for a query, a <code>cts:element-value-query</code> for "he*" will
  not match because the wildcard matches do not span word boundaries, but a
  <code>cts:element-value-query</code> for "hello *" will match.  A search
  for "*" will match, because a "*" wildcard by itself is defined to match
  the value.  Similarly, stemming rules are applied to each term, so a
  search for "hello friends" would match when stemming is enabled for the query
  because "friends" matches "friend". For an example, see the
  <a href="#evq4">fourth example</a> below.</p>
  <p xmlns="http://www.w3.org/1999/xhtml"> Similarly, because a "*" wildcard by itself is defined to match
  the value, the following query will match any element with the
  QName <code>my-element</code>, regardless of the wildcard indexes enabled in
  the database configuration:
  <pre><code>cts:element-value-query(xs:QName("my-element"), "*", "wildcarded")</code></pre>
  </p>
</api:usage><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
  cts.search(
    cts.elementValueQuery(
      xs.QName("function"),
      "MarkLogic Corporation"));
  
  =&gt; .. relevance-ordered sequence of documents
  having 'function' elements whose text
  content equals 'MarkLogic Corporation'.
</pre></api:example><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
  cts.search(
    cts.elementValueQuery(
      xs.QName("function"),
      "MarkLogic Corporation", "case-insensitive"));
  
  =&gt; .. relevance-ordered sequence of documents
  having 'function' elements whose text
  content equals 'MarkLogic Corporation', or any other
  case-shift like 'MARKLOGIC CorpoRation'.
</pre></api:example><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
  cts.search(
    cts.andQuery([
      cts.elementValueQuery(
        xs.QName("function"),
        "MarkLogic Corporation",
        "punctuation-insensitive", 0.5),
      cts.elementValueQuery(
        xs.QName("title"),
        "Word Query")]));
  =&gt; .. relevance-ordered sequence of documents having both:
  (a) 'function' elements with text content equal to
      'MarkLogic Corporation', ignoring embedded
      punctuation,
  AND
  (b) 'title' elements with text content equal to
      'Word Query', with the results of the first sub-query
      query given weight 0.5, and the results of the second
      sub-query given the default weight 1.0.  As a result,
      the title phrase 'Word Query' counts more heavily
      towards the relevance score.
</pre></api:example><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
var node = xdmp.unquote('&lt;my-node&gt;hello friend&lt;/my-node&gt;').next().value.root;
var res = new Array();
res.push(cts.contains(node, cts.elementValueQuery(xs.QName('my-node'),
      "hello friends", "stemmed")));
res.push(cts.contains(node, cts.elementValueQuery(xs.QName('my-node'),
      "he*", "wildcarded")));
res.push(cts.contains(node, cts.elementValueQuery(xs.QName('my-node'),
      "hello f*", "wildcarded")));
res;

=&gt; [true, false, true]
</pre></api:example></api:function></api:function-page>