[MarkLogic Dev General] Difference between two queries

Glidden, Douglass A Douglass.A.Glidden at boeing.com
Tue Oct 13 05:31:48 PDT 2009


Rahul,

The fn:doc function takes a URI (a string), but in your second case you are passing it whatever is selected by the XPath /documents/book2-which is most likely an empty sequence, which is automatically cast to an empty string.  If the URI of your document is really /documents/book2, then you need to put that inside quotes (either single or double will work), thus:  fn:doc("/documents/book2")//book/@year=2002.  My guess is that the URI is actually /documents/book2.xml, in which case the ".xml" must be included inside the quotes:  fn:doc("/documents/book2.xml")//book/@year=2002.

Basically, a URI is a string, not an XPath, so when you enter one manually you must enclose it in quotes.

Doug Glidden
Software Engineer
The Boeing Company
Douglass.A.Glidden at boeing.com



  _____

From: general-bounces at developer.marklogic.com [mailto:general-bounces at developer.marklogic.com] On Behalf Of Rahul Saluja
Sent: Monday, October 12, 2009 15:26
To: General Mark Logic Developer Discussion
Subject: [MarkLogic Dev General] Difference between two queries


hello all,

i am in a flux to understand whats the difference between following two queries

fn:doc(xdmp:node-uri( cts:search(//books,cts:and-query((cts:element-word-query(xs:QName("title"),"human" , ("wildcarded", "case-insensitive")),cts:element-word-query
(
xs:QName("status"),"Unavai* " ,

("wildcarded", "case-insensitive")

)
))
)))//book/@year=2002

returns TRUE

AND

fn:doc(/documents/book2)//book/@year=2002
 Returns FALSE

Argument to first query also returns the uri of document which satisfies the search criteria whereas when i pass this Uri by myself it returns false.

please reply.

regards
Rahul Saluja


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://xqzone.marklogic.com/pipermail/general/attachments/20091013/537c5a9a/attachment.html


More information about the General mailing list