I am new to MarkLogic.
I have XML doc
<?xml version="1.0" encoding="UTF-8"?>
<books xmlns="http://www.marklogic.com/ns/gs-books">
<book bookid="2">
<title>A Quick Path to an Application</title>
<author>
<last>Smith</last>
<first>James</first>
</author>
<publisher>Scribblers Press</publisher>
<isbn>1494-3930392-4</isbn>
<abstract>
This book describes in detail the power of how
to use Java to build powerful web applications
that are built on the MarkLogic Server platform.
</abstract>
</book>
</books>
How can I use cts:element-values
against it?
Here is my try: cts:element-values(xs:QName("test"),"test")
It gives me this error:
[1.0-ml] XDMP-ELEMRIDXNOTFOUND: cts:element-values(fn:QName("","t"), "t") -- No element range index for t collation=http://marklogic.com/collation/ coordinate-system=wgs84 [marklogic]
In order to be able to use cts:element-values()
, the element needs to have a corresponding range-index to use.
Returns values from the specified element value lexicon(s). Value lexicons are implemented using range indexes; consequently this function requires an element range index for each element specified in the function. If there is not a range index configured for each of the specified elements, an exception is thrown.
So, in order to be able to run: cts:element-values(xs:QName("test"),"test")
You would first need to create a String range index for the "test
" element (and ensure the reindexer is enabled, and allow for it to finish reindexing the docs with that element, in order to build the lexicon).
You can configure an element-range-index in the Admin UI, programmatically with admin:database-add-range-element-index()
, and if you have an ml-gradle project they can be added to the database configuration.