Hi Danny,
I assume there are separate logging docs/fragments for user activities on books vs chapters vs subjects? In that case you could take the following approach: - Use search:parse to convert the search string into a cts:query object - Use cts:and-query and something like cts:element-attribute-value-query to combine it with a restriction on books, chapters or subjects - Make for each type two calls using cts:values on the date/timestamp element/attribute, one ascending with limit=1, the other descending with limit=1 - Cast the values to xs:dateTime and substract them. That gives you a xs:duration for each. Don’t worry about the multiple cts calls, they are very fast. Taking this approach it should return user activities in sub sec. Using aggregation like you intended it could easily become minutes or even hours (depending on database size). Kind regards, Geert *Van:* general-boun...@developer.marklogic.com [mailto: general-boun...@developer.marklogic.com] *Namens *Danny Sinang *Verzonden:* dinsdag 8 mei 2012 16:25 *Aan:* MarkLogic Developer Discussion *Onderwerp:* Re: [MarkLogic Dev General] How to get max value in ML Hi Geert, We're logging user activities with regards to accessing a book (flipping through pages, annotating, etc). search:search() is used to fetch the logs that meet some reporting criteria (i.e. date range, which books, which chapters, etc). Once we get the filtered results, we feed them to a function to get the time spent by a user per book, chapter or subject. Time spent is the aggregate value. Regards, Danny On Tue, May 8, 2012 at 10:15 AM, Geert Josten <geert.jos...@dayon.nl> wrote: Hi Danny, Can you elaborate on the aggregate values? That is probably quite in-efficient too. You might be better off doing such work directly with cts functions, if possible. Kind regards, Geert *Van:* general-boun...@developer.marklogic.com [mailto: general-boun...@developer.marklogic.com] *Namens *Danny Sinang *Verzonden:* dinsdag 8 mei 2012 16:10 *Aan:* MarkLogic Developer Discussion *Onderwerp:* Re: [MarkLogic Dev General] How to get max value in ML Hi Geert, Thanks. Yes, you have a good point there. Returning all those results will be inefficient. But I'll be forcing the users to limit the results by date instead and we'll be imposing a maximum date range. I just need to make sure search:search() returns all the results because I'm feeding the entire result set to a function that computes for some aggregate values. Regards, Danny On Tue, May 8, 2012 at 10:04 AM, Geert Josten <geert.jos...@dayon.nl> wrote: Hi Danny, There is no pre-declared constant as far as I know if that is what you mean. But I’m sure it follows the specs of the XML Schema standard. Are you sure you want search:search to return so many results in one call? It is memory in-efficient, and showing so many results in for instance in a browser is likely to choke the browser. If you’d use a crawler that supports parallel threads, you’d see that a page size of something like 100 to 500 would work much better.. Kind regards, Geert *Van:* general-boun...@developer.marklogic.com [mailto: general-boun...@developer.marklogic.com] *Namens *Danny Sinang *Verzonden:* dinsdag 8 mei 2012 15:58 *Aan:* MarkLogic Developer Discussion *Onderwerp:* Re: [MarkLogic Dev General] How to get max value in ML Hi Geert, I'm trying to get the maximum unsigned long value to tell seach:search() to return all results. I was hoping there would be an ML function out there that would tell me the max unsigned long value. Regards, Danny On Tue, May 8, 2012 at 9:54 AM, Geert Josten <geert.jos...@dayon.nl> wrote: Hi Danny, Can you elaborate on what you exactly mean? Given a sequence, you can just use fn:max() to get the highest value. If you want to determine the highest value that occurs anywhere in the database, you can use cts:values with a descending order and limit of 1. The first and single result is the highest.. Kind regards, Geert *Van:* general-boun...@developer.marklogic.com [mailto: general-boun...@developer.marklogic.com] *Namens *Danny Sinang *Verzonden:* dinsdag 8 mei 2012 15:49 *Aan:* general *Onderwerp:* [MarkLogic Dev General] How to get max value in ML Hi, Is there a function in ML that returns the maximum values for integer and unsigned long ? Regards, Danny _______________________________________________ General mailing list General@developer.marklogic.com http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list General@developer.marklogic.com http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list General@developer.marklogic.com http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________ General mailing list General@developer.marklogic.com http://developer.marklogic.com/mailman/listinfo/general