0

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?

EboMike
  • 76,846
  • 14
  • 164
  • 167
  • Sorry - hit the submit button before realising - good call :) –  Dec 23 '10 at 20:07
  • we don't know what docs is, or results, or ToIndexDefinition(). Have you looked at the query result for Map and Reduce seperately? There is not enough information here for me. – tster Dec 23 '10 at 20:31
  • this is RavenDb standard stuff - do you know what ravendb is? [annoying] [grrr] [dont chip in unless you know what you're talking about] –  Dec 23 '10 at 20:38
  • Just had to change all TagName to match Name and it mapped nicely. working like a charmio –  Dec 23 '10 at 21:03

1 Answers1

0

Just had to change all TagName to match Name and it mapped nicely