It looks to me like you have the right idea there, but there are a few details
that are not quite right.
(Also, you might think about upgrading to 3.2)
What I tried is the following:
* created Int range indexes on the elements intValueLo and intValueHi elements
* inserted the following into that database (your XML had malformed end tags
for intValueHi):
let $x := <results>
<tagA>
<intValueLo>0</intValueLo>
<intValueHi>100</intValueHi>
</tagA>
<tagA>
<intValueLo>20</intValueLo>
<intValueHi>200</intValueHi>
</tagA>
<tagA>
<intValueLo>30</intValueLo>
<intValueHi>300</intValueHi>
</tagA>
<tagA>
<intValueLo>40</intValueLo>
<intValueHi>400</intValueHi>
</tagA>
<tagA>
<intValueLo>50</intValueLo>
<intValueHi>500</intValueHi>
</tagA>
</results>
return xdmp:document-insert("/ray/test.xml", $x)
* run the following query (I reversed the Hi and Lo parts of your cts:query, as
the way it was written it produced no results--probably you want a different
value for hi and lo though):
let $inputInt := 250
let $query := cts:and-query((
cts:element-range-query(xs:QName("intValueHi"), ">=", $inputInt),
cts:element-range-query(xs:QName("intValueLo"), "<=", $inputInt)
))
return
cts:search(//tagA, $query)
This returns:
<tagA><intValueLo>30</intValueLo><intValueHi>300</intValueHi></tagA>
<tagA><intValueLo>40</intValueLo><intValueHi>400</intValueHi></tagA>
<tagA><intValueLo>50</intValueLo><intValueHi>500</intValueHi></tagA>
-Danny
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tony Mariella
Sent: Monday, September 08, 2008 1:29 PM
To: [email protected]
Subject: [MarkLogic Dev General] FW: Marklogic 3.1
I am a software developer currently using Marklogic 3.1.
I have a technical question:
I am trying to do a nested range query:
If I have this xml contained in the ML database, is it possible to do a range
search on this data:
<results>
<tagA>
<intValueLo>0</intValueLo>
<intValueHi>100</intValue>
</tagA>
<tagA>
<intValueLo>20</intValueLo>
<intValueHi>200</intValue>
</tagA>
<tagA>
<intValueLo>30</intValueLo>
<intValueHi>300</intValue>
</tagA>
<tagA>
<intValueLo>40</intValueLo>
<intValueHi>400</intValue>
</tagA>
<tagA>
<intValueLo>50</intValueLo>
<intValueHi>500</intValue>
</tagA>
</results>
What I want to do is a range query given an input value: $inputInt := 250
If I do this:
cts:and-query((
cts:element-range-query(xs:QName("intValueLo"), ">=", $inputInt),
cts:element-range-query(xs:QName("intValueHi"), "<=", $inputInt)
))
This seems to take all the intValueLo values and all the intValueHi values and
does a range query between them.
Is there a solution to this problem ? Email response is preferred.
Thank you,
Tony Mariella
Raytheon Company
(240) 373-5559
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general