Hi,

  I created an element-attribute-range-index that works just fine in a standard 
range constraint, but not working in a custom constraint when manually parsed.

Here is a snippet of the data: stripped down to show only the relevance.

xmlns:accreditation=http://optimus.com/view/accreditation
...

<accreditation:export accreditation:totalCredits="1.0" >
</accreditation:export>


Here is the script to create the index: Note that the doc say collation should 
be "" unless the type is string or anyURI, but I also try setting it to 
http://marklogic.com/collation/ with no different result

xquery version "1.0-ml";
import module namespace admin = "http://marklogic.com/xdmp/admin";
         at "/MarkLogic/admin.xqy";

let $config := admin:get-configuration()
let $dbid := xdmp:database("OPTIMUS_SEARCH_DEV")
let $rangespec := admin:database-range-element-attribute-index(
         "float",
         "http://optimus.com/view/accreditation";,
         "export",
         "http://optimus.com/view/accreditation";,
         "totalCredits",
         "",
         fn:false())

return admin:save-configuration(
  admin:database-add-range-element-attribute-index(
         $config,
         $dbid,
         $rangespec))

This standard range constraint works just find for query like (totalCredits GE 
5.5):

                <search:constraint name="totalCredits">
                    <search:range type="xs:float" facet="false">
                        <search:element 
ns="http://optimus.com/view/accreditation"; name="export"/>
                        <search:attribute 
ns="http://optimus.com/view/accreditation"; name="totalCredits"/>
                    </search:range>
                </search:constraint>

Also this script verify that the range index was created:

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

declare variable $dbname := "OPTIMUS_SEARCH_DEV";

let $config := admin:get-configuration()
return
(admin:database-get-range-element-attribute-indexes($config, 
xdmp:database($dbname) ),
  admin:database-get-reindexer-enable($config,  xdmp:database($dbname)) ),

try {
xdmp:eval('xquery version "1.0-ml"; declare namespace accreditation = 
"http://optimus.com/view/accreditation";; 
cts:element-attribute-value-query(xs:QName("accreditation:export"), 
xs:QName("accreditation:totalCredits"), "5.5")', (),
<options xmlns="xdmp:eval">
<database>{xdmp:database($dbname)}</database>
</options>)
}
catch ($e) { $e }

But a custom constraint like this failed:

                <search:constraint name="creditsAccredited">
                    <search:custom facet="false">
                        <search:parse apply="parse" 
ns="http://optimus.com/view/facet";
                                      at="/creditsAccredited.xqy"/>
                    </search:custom>
                </search:constraint>

File creditsAccredited.xqy has this:

let $creditsPortion :=
    cts:element-attribute-range-query(xs:QName("accreditation:export"), 
xs:QName("accreditation:totalCredits"), ">=", "5.5")

let $query := <root>{cts:element-query(xs:QName("accreditation:export"), 
$creditsPortion)}</root>/*

The error is: Note that when no collation is given, ML seems to pick 
http://marklogic.com/collation/codepoint . If I set (collation='') then it 
failed to validate the URI. I then tried to recreate the range index with this 
collation, but it simply ignored and always reported as an empty string.

XDMP-ELEMATTRRIDXNOTFOUND: cts:search(fn:collection(), 
cts:and-query((cts:collection-query("type/program"), cts:word-query("Andrew 
Test LC", ("lang=en"), 1), 
cts:element-query(fn:QName("http://optimus.com/view/accreditation";, "export"), 
cts:element-attribute-range-query(fn:QName("http://optimus.com/view/accreditation";,
 "export"), fn:QName("http://optimus.com/view/accreditation";, "totalCredits"), 
">=", "9.0", ("collation=http://marklogic.com/collation/codepoint";), 1), ()), 
...), ()), ("score-logtfidf", "faceted"), 1) -- No string element-attribute 
range index for fn:QName("http://optimus.com/view/accreditation";, "export") 
fn:QName("http://optimus.com/view/accreditation";, "totalCredits") 
http://marklogic.com/collation/codepoint

Did I miss something here? Please help.

Thank you.
Luan


_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to