Hi Danny,

Yes, I have default namespace declared. I tried the query in cq,

xquery version "1.0-ml";
(: buffer 2 :)
declare namespace html = "http://www.w3.org/1999/xhtml";;
declare default element namespace "http://tpox-benchmark.com/custacc";;

xdmp:query-trace(true()),(
for $cust in doc()
where $cust/Customer/@id = 1002
return $cust
)

I don't know why. Thank you very much!

Ling


Danny Sokolsky wrote:
> What namespace is your element and attribute in, and what namespace is your 
> range index in?  It looks (according to the query trace) like both the 
> element and the attribute are in the http://tpox-benchmark.com/custacc 
> namespace, but the first query is requesting the id attribute in no 
> namespace.  Maybe somewhere here lies the clue?  Do you have any default 
> namespaces in play here?
> 
> -Danny 
> 
> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of Ling Ling
> Sent: Wednesday, May 05, 2010 3:53 PM
> To: [email protected]
> Subject: [MarkLogic Dev General] attribute range index
> 
> Hello,
> 
> I have a question about query and attribute range query
> I have a customer xml file stored in database and an attribute range 
> index on Customer id, if my query is like:
> 
> for $cust in doc()
> where $cust/Customer/@id = 1002
> return $cust
> 
> The range index is not used and the trace file is here:
> 
> Info: benchHttp: line 7: xdmp:eval("xquery version 
> &quot;1.0-ml&quot;;&#13;&#10;(: buffer 2 :)&#13;&...", (), <options 
> xmlns="xdmp:eval"><root>benchHttp</root><isolation>different-transaction</isolatio...</options>)
> Info: benchHttp: line 7: Analyzing path for $cust: fn:doc()
> Info: benchHttp: line 7: Step 1 is searchable: fn:doc()
> Info: benchHttp: line 7: Path is fully searchable.
> Info: benchHttp: line 7: Gathering constraints.
> Info: benchHttp: line 7: Step 1 contributed 1 constraint: fn:doc()
> Info: benchHttp: line 8: Comparison contributed hash value constraint: 
> Customer/@id = 1002
> Info: benchHttp: line 7: Where clause contributed 2 constraints for 
> $cust: $cust/Customer/@id = 1002
> Info: benchHttp: line 7: Executing search.
> Info: benchHttp: line 7: Selected 1 fragment to filter
> 
> If I wrote query like this:
> 
> cts:search(doc()/Customer,
> cts:element-attribute-range-query(xs:QName("Customer"), xs:QName("id"), 
> "=" ,1002))
> 
> xdmp:query-trace(true()),(
> cts:search(doc()/Customer,
> cts:element-attribute-range-query(xs:QName("Customer"), xs:QName("id"), 
> "=" ,1002))
> )
> 
> The index is used but no results returned. Here is the trace file:
> 
> line 7: xdmp:eval("xquery version &quot;1.0-ml&quot;;&#13;&#10;(: buffer 
> 2 :)&#13;&...", (), <options 
> xmlns="xdmp:eval"><root>benchHttp</root><isolation>different-transaction</isolatio...</options>)
> line 7: Analyzing path for search: fn:doc()/Customer
> line 7: Step 1 is searchable: fn:doc()
> line 7: Step 2 is searchable: Customer
> line 7: Path is fully searchable.
> line 7: Gathering constraints.
> line 7: Step 2 test contributed 1 constraint: Customer
> line 7: Comparison contributed int range value constraint: Customer/@id 
> = 1002
> line 7: Search query contributed 1 constraint: 
> cts:element-attribute-range-query(fn:QName("http://tpox-benchmark.com/custacc";,
>  
> "Customer"), fn:QName("http://tpox-benchmark.com/custacc";, "id"), "=", 
> 1002, (), 1)
> line 7: Executing search.
> line 7: Selected 0 fragments to filter
> 
> Could you show me the reason? Thank you very much!
> 
> Regards,
> Ling
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
> 
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to