I have a City document, Site document. City can have multiple sites. Site document has the city information in it. There are about 100 city documents and 10000 site documents in RavenDB
City Document:
{
"CityCode": "NY",
"CityName": "New York"
}
Site Document:
{
"SiteName": "MOMA",
"CityCode": "NY"
}
Objective is to get a list of all cities and the number of sites for each like…
City Sites NY 12 CH 33 BO 56 and so on....
I am doing this.
int countSites = session.Query<Site>()
.Count();
var SiteCityList = session.Query<Site>()
.Take(countSites)
.ToList()
.GroupBy(x => x.CityCode)
.OrderBy(x => x.Count())
.ToDictionary(x => x.Key, x => x.Count());
This does not give all the data in the ravendb. I get only 11 rows of count by site at any time and even the counts are not accurate. What I want is to get a list of all 100 cities and number of sites for each city (in 100s) as a list as shown above. Thanks for the help.
Use a map/reduce index like this
Later then, you can query it easily.