[MarkLogic Dev General] Problem in making use of cts:not-query()

Geert Josten geert.josten at dayon.nl
Thu Mar 22 13:55:49 PDT 2012

Hi Subheer,

Such queries in MarkLogic look at entire fragments, in this case the whole
userdetails xml. Easiest way out is to define user as fragment root within
the admin interface. But you might also consider chopping userdetails and
storing each user as a separate document.

Kind regards,


*Van:* general-bounces at developer.marklogic.com [mailto:
general-bounces at developer.marklogic.com] *Namens *Sudheer Yalaverthi
*Verzonden:* donderdag 22 maart 2012 21:48
*Aan:* general at developer.marklogic.com
*Onderwerp:* [MarkLogic Dev General] Problem in making use of

Hi Team,

My sample XML would be like this.

    <user branch="CSE">
    <user branch="CSE">
    <user branch="IT">

I have a requirement where i should pick this Xml from the DB if there is a
user entry with branch as"CSE" and id =222 and it should not have "C" as

If i write a additional query something like below for search:search()
      cts:element-value-query(xs:QName("id"), "222"),
xs:QName("branch"), "CSE"),
      cts:not-query(cts:element-value-query(xs:QName("subject"), "C"))

This is not turning me up the results. The only one scenario this query is
gonna return back the result is if none of the users in the DB has the
subject as "C". but this is not i am expecting. I know there is one user
element which satisfies all the conditions and other user elements which
fail these connditions. I want to retrieve the Xml even if one of the user
element passes all these conditions irrespective of other elements pass or
fail. Please suggest me.
I am using search:search and i can not avoid this as i have some other
requirements to sorting the result Xmls.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20120322/028f263a/attachment.html 

More information about the General mailing list