RavenDB 4 - Aggregation facet operations without the aggregation

30 views
Skip to first unread message

Andrej Krivulčík

unread,
Jan 12, 2018, 9:39:06 AM1/12/18
to RavenDB - 2nd generation document database
I'd like to calculate the aggregation operations which are available for faceted queries (sum, max, min, average) on a query, but for a whole data set, not the aggregated parts.

E.g. I have a query like

var query = session.Query<Doc, DocIndex>().Where(...);

var aggregatedSums = query.AggregateBy(builder => builder.ByField(x => x.Category).SumOn(x => x.SomeValue));

This works perfectly for the results aggregated by the category.

Is there a clever way how to sum the values for all documents matched by the query?

Using a trick like this to put them all in one category:

var sum = query.AggregateBy(builder => builder.ByField(x => 1).SumOn(x => x.SomeValue));

doesn't work:

Raven.Server.Documents.Queries.Parser.QueryParser+ParseException: 1:117 parsing method, expected an argument but got: ,
Query: 
from index 'DocIndex' where [...] select facet(, avg(SomeValue))

I can do the aggregated query and find max/min and do weighted average myself but I feel that there should be a more elegant solution.

Oren Eini (Ayende Rahien)

unread,
Jan 13, 2018, 6:56:36 AM1/13/18
to ravendb

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages