Created
October 10, 2019 18:45
-
-
Save prestonmcgowan/7f7c39e91b19f65d3c7756603e78edba to your computer and use it in GitHub Desktop.
Example of an Empty Element Query with MarkLogic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(: Create sample docs :) | |
xquery version "1.0-ml"; | |
( | |
xdmp:document-insert("/test/zero.xml", <doc><a>1</a><b>1</b><c>1</c><d>1</d></doc>), | |
xdmp:document-insert("/test/one.xml", <doc><a>1</a><b>1</b><c>1</c><d></d></doc>), | |
xdmp:document-insert("/test/two.xml", <doc><a>1</a><b>1</b><c></c><d></d></doc>), | |
xdmp:document-insert("/test/three.xml", <doc><a>1</a><b></b><c></c><d></d></doc>), | |
xdmp:document-insert("/test/four.xml", <doc><a></a><b></b><c></c><d></d></doc>) | |
) | |
; | |
(: Count empty documents for each value :) | |
xquery version "1.0-ml"; | |
for $x in ("a", "b", "c", "d", "e") | |
return ($x, | |
xdmp:estimate(cts:search(fn:doc(), cts:element-value-query(xs:QName($x), "" ) )) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment