Multiple SortByCount's in on Query? is it possible?


I presently have 4 dropdowns I populate from the results of 4 separate sortByCount() queries.

Is it possible to do this in one query? probably using a different bucket/facet method. Probably making use of addToSet or Push or something.

Many thanks

It isn’t clear [to me] what you want are doing and want to do. Can you provide an example document from your collection and your current query(ies) so I can better understand your question?

Thanks Eric,

I have a collection with a number of fields, and four of them are
location, skill, sector and activitytype

location for example as say, 10 possible values from 1000 documents.
I.e. any of those 1000 documents will only have one of 10 values.

skill might have 5 unique values , and so on.

I have a web search form where I populate a drop down for each of; location, sector, skill, activityrtype with the value and how many times that value occurs in the result set.

But I have to make 4 seperate queries like this in the c# class which gets the data for the view model.

        = MongoClient.
            GetSortByCount(UserCriteria, x => x.Location, User);

        = MongoClient.
            GetSortByCount(UserCriteria, x => x.Activity, User);

        = MongoClient.
            GetSortByCount(UserCriteria, x => x.Sector, User);

        = MongoClient.
            GetSortByCount(UserCriteria, x => x.Skill, User); 

Each of the above is doing the following

            Results =
                    SortBy(x => x.Id).

Can I do the above for 4 fields and get for lists of unique values and their occurrence type?
e.g. get the date for four dropdowns like the following at once.


For those reading this (I expect Eric knows this) and looking at the seemingly hard coded
SortBy(…) SortByCount() returns the same class always and Id is the unique value in the list. so x.Id is always present.