We need to calculate max values of two nodes for a given search query. From
MarkLogic documentation we could see that we could achieve this using
values in the options node of search:search. Example below:
We have 2 documents:
<document>
<name>abc</name>
<size>12</size></document>
<document>
<name>abc</name>
<size>4</size></document>
We tried to find the max/min using search:search as below:
xquery version "1.0-ml";declare namespace html = "http://www.w3.org/1999/xhtml";
import module namespace search =
"http://marklogic.com/appservices/search" at
"/MarkLogic/appservices/search/search.xqy";
declare variable $options :=
<options xmlns="http://marklogic.com/appservices/search">
<values name="example">
<range type="xs:int">
<element ns="" name="size"/>
</range>
<aggregate apply="max"/>
</values>
</options>;
search:search("abc", $options)
this does not return values-response node which this documentation claims:
http://docs.marklogic.com/search:search#opt-values
If we use search:values as below then it returns values-response:
xquery version "1.0-ml";declare namespace html = "http://www.w3.org/1999/xhtml";
import module namespace search =
"http://marklogic.com/appservices/search" at
"/MarkLogic/appservices/search/search.xqy";
declare variable $options :=
<options xmlns="http://marklogic.com/appservices/search">
<values name="example">
<range type="xs:int">
<element ns="" name="size"/>
</range>
<aggregate apply="max"/>
</values>
</options>;search:values("example", $options)
Output:
<search:values-response name="example" type="xs:int"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:search="http://marklogic.com/appservices/search">
<search:distinct-value frequency="1">4</search:distinct-value>
<search:distinct-value frequency="1">12</search:distinct-value>
<search:aggregate-result name="max">12</search:aggregate-result>
<metrics xmlns="http://marklogic.com/appservices/search">
<values-resolution-time>PT0.001927S</values-resolution-time>
<aggregate-resolution-time>PT0.00242S</aggregate-resolution-time>
<total-time>PT0.005973S</total-time>
</metrics>
</search:values-response>
Theoretically this should work with search:search as well but somehow it
completely ignores values node. Are we missing something obvious here or
some other config is needed?
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general