I am trying to find co-occurrences of all documents which have a property <id>
in the document-properties.. Following is the code I am doing to list the co-occurrences and is not working.. can someone suggest what I am doing wrong.
xquery version "1.0-ml";
declare namespace html = "http://www.w3.org/1999/xhtml";
declare namespace prop = "http://marklogic.com/xdmp/property";
import module namespace search = "http://marklogic.com/appservices/search" at "/MarkLogic/appservices/search/search.xqy";
cts:value-co-occurrences(
cts:element-reference(xs:QName('prop:id')),
cts:uri-reference())
Note: I have edited this answer after acceptance because I gave three items to look at. The edit is to highlight the part of the answer that gave the solution
Solution: - Namespace in properties fragment was different
Original wording of response:
Are you sure the element in question is actually in the properties namespace as your index shows? A quick dump of cts:element-values may show this. I mention this because adding properties to the properties fragment does not infer that they are in the properties namespace.
Other ideas - not the answer, but path of investigation
I think you are looking for cts:value-tuples and not co-occurance based on your example.
However: from your problem statement, why do you not just use cts:uris() constrained by an cts:element-query() on the property fragment (and all without a range index)
This can tell you all URIs where element my-element exists in the properties fragment:
cts:uris("", (),
cts:properties-fragment-query(
cts:element-query(xs:QName("my-element"),
cts:and-query( () ))
)
)