Hi,
We need to build a dynamic query builder in MarkLogic.
We are trying to build using cts:element-query to reach to the exact path(
there are many elements with the same name).We cant use path range queries as
its dynamic qurey builder so cant create index on each element of the xml.
But the cts:element query is not returning the correct results( its giving
those documents also in which termination/primaries/currencies/currency is not
equal to USD).
Please let me know how this can be achieved,as there are other currency element
in xml at other xpath.
let $path :="termination/primaries/currencies/currency"
let $elems :=fn:tokenize($path,"/")
let $elem :=$elems[last()]
let $valueType :=""
let $values :="USD"
let $query :=<cts:and-query>
{for $each in $elems
where $each ne $elem
return
<cts:element-query>
<cts:element>{$each}</cts:element>
<cts:and-query/>
</cts:element-query>
}
<cts:element-query>
{for $each in $elems
where $each ne $elem
return
<cts:element>{$each}</cts:element>}
<cts:element-value-query
xmlns:cts="http://marklogic.com/cts">
<cts:element>{$elem}</cts:element>
{for $value in $values
return
<cts:text xml:lang="en">{if ($valueType
= 'Decimal') then xs:float($value) else $value}</cts:text>}
<cts:option>case-insensitive</cts:option>
</cts:element-value-query>
</cts:element-query>
</cts:and-query>
let $query :=cts:query($query)
return xdmp:estimate(cts:search(collection("data"),$query))
"This e-mail and any attachments transmitted with it are for the sole use of
the intended recipient(s) and may contain confidential , proprietary or
privileged information. If you are not the intended recipient, please contact
the sender by reply e-mail and destroy all copies of the original message. Any
unauthorized review, use, disclosure, dissemination, forwarding, printing or
copying of this e-mail or any action taken in reliance on this e-mail is
strictly prohibited and may be unlawful."
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general