<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/cts.relevanceInfo.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>cts.relevanceInfo</api:function-name><api:suggest>cts.relevanceinfo</api:suggest><api:suggest>cts</api:suggest><api:suggest>relevanceinfo</api:suggest><api:function-link mode="xquery" fullname="cts:relevance-info">/apidoc/8.0/cts:relevance-info.xml</api:function-link><api:function mode="javascript" name="relevanceInfo" type="builtin" lib="cts" category="SearchBuiltins" subcategory="Search" hidden="false" bucket="MarkLogic Built-In Functions" prefix="cts" namespace="http://marklogic.com/cts" fullname="cts.relevanceInfo"><api:summary>
  Return the relevance score computation report for a node.
</api:summary><api:params><api:param name="node" type="node()" optional="true"><api:param-description>
    A node. Typically this is an item in the result sequence of a
    
    <span class="javascript" xmlns="http://www.w3.org/1999/xhtml"><code>cts.search</code></span> operation. 
    If this parameter is omitted, the context node is used.
  </api:param-description><api:param-name>node</api:param-name><api:param-type>Node</api:param-type></api:param><api:param class="javascript" name="output-kind" type="xs:string" optional="true"><api:param-description>
    The output kind. It can be either "object" or "element".
    With "object",  the built-in returns an object.
    With "element", the built-in returns an XML element node.
    The default is "object".
  </api:param-description><api:param-name>output-kind</api:param-name><api:param-type>String</api:param-type></api:param></api:params><api:return class="javascript">Object</api:return><api:usage>
  <p xmlns="http://www.w3.org/1999/xhtml">
    This function returns 
    <span class="javascript">a JavaScript object</span> that contains 
    details about the
    score computation only if the following conditions are met:
    The <code>node</code> parameter or context node is the result
    of a 
    <span class="javascript"><code>cts.search</code></span> call that 
    included the <code>relevance-trace</code> option; and the score is 
    non-zero. For
    example, you will not get a report if you use the <code>score-zero</code>
    option on your 
    <span class="javascript"><code>cts.search</code></span>, if the 
    search returns no results, or if <code>node</code> is not the result 
    of 
    <span class="javascript"><code>cts.search</code></span>.
  </p><p xmlns="http://www.w3.org/1999/xhtml">
    The score computation reflects the scoring method specified in the
    
    <span class="javascript"><code>cts.search</code></span> expression, 
    if any. The <code>score-zero</code> and <code>score-random</code> 
    methods do not generate a report.
  </p><p xmlns="http://www.w3.org/1999/xhtml">
    Collecting score computation details with which to generate this report
    is costly, so using the <code>relevance-trace</code> option will
    slow down your search significantly.
  </p>
</api:usage><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
var x = cts.search("dog", ["relevance-trace"]).toArray();
cts.relevanceInfo(x[0]);
=&gt;
{
  "score":{
    "formula":"(256*scoreSum/weightSum)+(256*qualityWeight*documentQuality)",
    "computation":"(256*8/1)+(256*1*0)",
    "value":2048
  },
  "confidence":{
    "formula":"sqrt(score/(256*8*maxlogtf*maxidf))",
    "computation":"sqrt(2048/(256*8*18*log(1)))",
    "value":0
  },
  "fitness":{
    "formula":"sqrt(score/(256*8*maxlogtf*avgidf))",
    "computation":"sqrt(2048/(256*8*18*(0/1)))",
    "value":0.2357023
  },
  "uri":"othello.xml",
  "path":"fn:doc('othello.xml')",
  "term":{
    "weight":0.125,
    "score":{
      "formula":"8*weight*logtf",
      "computation":"1*8",
      "value":8
    },
    "key":"5166487143365525844",
    "annotation":"word(\"dog\")"
  }
}
}</pre></api:example></api:function></api:function-page>