From: Mike A. <mi...@au...> - 2012-05-03 07:56:43
|
I'm writing some code at the minute and I have two main issues outstanding.. 1) I want to aggregate data based on a user defined query - this means searching through an index when I have a new record to see if a record already exists If it does - I want to update the totals in there with some new value. If it does not exist - I want to create a new document containing my totals to store in a secondary index - but only have the fields that are used in the query.. So - is there any way to traverse the Query to find out what fields are used - so I can create a new document which only contains those fields ? 2) When I pull the data back at the end - I want to be able to order the data by these totals - based on some query. So - for example - I might aggregate all the sales by salesman and area, then select from that index for a particular area and have it ordered by the total sales. If it makes it any clearer - in SQL it would be something like - select salesman, area, sum(sales) GROUP BY 1,2 ORDER BY 3 desc (obviously - I'm not doing salesmen and sales - if I was I'd probably use a relational database - but you get the idea) Any ideas on how to solve these two issues? Many thanks in advance |