My data contains structures such as the following. First document: <doc> <foo><value>a</value></foo> <bar><value>b</value></bar> <person firstname="bob"/> </doc>
Second document: <doc> <foo><value>b</value></foo> <bar><value>a</value></bar> <person firstname="bob"/> </doc> The query string "foo:a" should only return the first document, so I cannot just create a constraint that uses a cts:element-range-query on the value element as that would match the children of bar as well as those of foo. I need a cts:element-query on "foo" that wraps a cts:element-word-query on "value". I implemented this via a custom parse function and created the below options node: <search:options xmlns:search="http://marklogic.com/appservices/search"> <search:constraint name="person"> <search:range collation="http://marklogic.com/collation/" type="xs:string" facet="true"> <search:attribute ns="" name="firstname"/> <search:element ns="" name="person"/> </search:range> </search:constraint> <search:constraint name="foo"> <search:custom facet="true"> <search:parse apply="parse-foo" ns="my_ns" at="/my/facet.xqy"/> <search:start-facet apply="start-custom-facet" ns="my_ns" at="/my/facet.xqy"/> <search:finish-facet apply="finish-custom-facet" ns="my_ns" at="/my/facet.xqy"/> </search:custom> </search:constraint> </search:options> I create a cts:query using search:parse, passing in the above options node which creates a cts:element-attribute-range-query. I call search:resolve passing in this query and the same options node. My parse-foo function creates the cts:element-query that I need. My start-custom-facet expects that the cts:query passed to it is of that type and makes the call to the lexicon to get the values. This works as desired for "foo:a", but when I use "person:bob" I get an XDMP-ARGTYPE error because the query passed to start-custom-facet is a cts:element-attribute-range-query, not a cts:element-query. This was easy to fix by testing the type of the query and returning an empty sequence if it is not a cts:element-query, but I was surprised that my custom start-facet function was called at all. >From the stack trace it appears that the query is passed through each of the >defined constraints invoking the custom start-facet function when it hits the >"foo" constraint. It would have been nice if the documentation had warned me >that the custom start-facet would be called for every query and needs to >handle non-custom constraint queries as well as those generated by the custom >parse function. Bob
_______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general
