i have an act:
public class Act
{
public Act()
{
this.Tags = new List<Tag>();
}
public string Id {get; set;}
public string Name { get; set; }
public IList<Tag> Tags { get; set; }
}
Tag is just:
public class Tag
{
public string Name { get; set; }
public string LfmUrl { get; set; }
}
I want to be able to query the DB and get a list of TagCount back which shows the name of the tag and the number of times it appears.
So far I have this:
public class Tags_ByTagCloud : AbstractIndexCreationTask
{
public override IndexDefinition CreateIndexDefinition()
{
return new IndexDefinition<Act, TagAndCount>
{
Map = docs => from doc in docs
from tag in doc.Tags
select new
{
Name = tag.Name,
Count = 1
},
Reduce = results => from result in results
group result by result.TagName
into g
select new
{
Name = g.Key,
Count = g.Sum(x => x.Count)
},
SortOptions = {{x => x.Count, SortOptions.Int}}
}.ToIndexDefinition(DocumentStore.Conventions);
}
}
Which happily outputs nothing. I know there are thousands of acts each with at least a few tags. Any ideas?
I ideally want to pass in a list of act ids to query this against. So, given a list of acts, what are the tags and how many times does each occur?
Just had to change all TagName to match Name and it mapped nicely