Hi Mark,

It unfortunately doesn’t work like that. It sounds like you are trying to get 
the average temperatures for all locations, maybe even ordered in a specific 
way? You can pull those numbers out of MarkLogic, but you will have to get the 
averages one by one for each location. That doesn’t have to be slow 
necessarily, but that will scale linearly against the number of locations.

What would you like to do with those numbers? Depending on how you want to use 
them, there might be different ways of approaching this in a smart way..

Cheers,
Geert

From: Mark Shanks <[email protected]<mailto:[email protected]>>
Reply-To: MarkLogic Developer Discussion 
<[email protected]<mailto:[email protected]>>
Date: Thursday, April 16, 2015 at 1:33 AM
To: "[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Subject: [MarkLogic Dev General] Returning of averages rather than counts

Hi,

I've been going through the analytics tutorial at 
https://developer.marklogic.com/learn/rest/analytics. I have a custom search 
returning an average on a variable. However, what is frequently needed is to 
return the average of a variable across another variable/facet. The tutorial 
shows how to produce constraints/facets, but doesn't show how to return 
averages across the constraint/facet. I was hoping that by nesting the code, 
the appropriate average would be returned, but the server seems to just ignore 
the average request (see below). What am I doing wrong?

xdmp:document-insert("/Default/climate/rest-api/options/tutorial.xml",
  <search:options xmlns:search="http://marklogic.com/appservices/search";>
    <search:constraint name="location">
    <search:range type="xs:string" facet="true" 
collation="http://marklogic.com/collation/";>
      <search:element ns="http://data/"; name="LOCATION_ID"

      <search:values name="temperature">
          <search:range type="xs:int">
           <search:element ns="http://data/"; name="TEMPERATURE_READING"/>
           </search:range>
         <search:aggregate apply="avg"/>
      </search:values>


      </search:element>
     </search:range>
  </search:constraint>
</search:options>
)

Thanks.
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to