How to get score of a registered-query
<p>I'm trying to calculate a score for a complex match query.
For example: </p>

<pre><code>if conditionA and conditionB and (conditionC or conditionD) 
then score = 10
else score = 0
</code></pre>

<p>This is the solution I've come up:</p>

<pre><code>let $idReq := cts:register(
  cts:and-query((
   cts:path-range-query("/person/name", "=", 'val1', ("score-function=linear", "collation=http://marklogic.com/collation//S1")),
   cts:path-range-query("/person/country", "=", 'country', ("score-function=linear", "collation=http://marklogic.com/collation//S1")),
   cts:or-query((
     cts:path-range-query("/person/city", "=", 'city', ("score-function=linear", "collation=http://marklogic.com/collation//S1")),
     cts:path-range-query("/person/school", "=", '', ("score-function=linear", "collation=http://marklogic.com/collation//S1"))
   ))
 ))
)
return
  cts:score(cts:search(fn:doc(), cts:registered-query($idReq, ("unfiltered"), 10)))
</code></pre>

<p>All the indexes exists and the collation too.</p>

<p>When I execute this registered query, I always get 0 for the score.</p>

<p><strong>EDITED</strong></p>

<p>I've narrow down the problem , and it can reproduced by combining cts:register with cts:path-range-query.</p>

<pre><code>let $query := cts:path-range-query("/person/name", "=", "val1", ("score-function=linear", "collation=http://marklogic.com/collation//S1"))
let $idReq := cts:register($query)
return 
  cts:score(
    cts:search(fn:doc(), 
      cts:registered-query($idReq,("unfiltered"), 10)
      (: $query :)
    )
  )
</code></pre>

<p><strong>EDITED</strong></p>

<p>Setup index config for testing:</p>

<pre><code>import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy";

let $dbid := xdmp:database("Documents")
let $config := 
  admin:database-add-range-path-index(
    admin:get-configuration(), $dbid, 
    admin:database-range-path-index(
      $dbid, "string", "/person/name",
      "http://marklogic.com/collation//S1",
      fn:false(), "ignore"))
return admin:save-configuration($config)
</code></pre>

<p>Sample data:</p>

<pre><code>xdmp:document-insert(
  '/test/person1.xml',
  &lt;person&gt;
    &lt;name&gt;val1&lt;/name&gt;
    &lt;city&gt;city&lt;/city&gt;
    &lt;country&gt;country&lt;/country&gt;
  &lt;/person&gt;
)
</code></pre>