只是另一个标签云问题
我有一个行为:
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; }
}
标签只是:
public class Tag
{
public string Name { get; set; }
public string LfmUrl { get; set; }
}
我希望能够查询数据库并获取 TagCount 列表,其中显示标签的名称及其出现的次数。
到目前为止,我有这个:
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);
}
}
很高兴没有输出任何内容。我知道有数千个行为,每个行为至少有几个标签。有什么想法吗?
理想情况下,我想传递一个 act id 列表来查询它。那么,给定一个行为列表,标签是什么以及执行了多少次 各发生?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需更改所有 TagName 以匹配 Name 并且它映射得很好
Just had to change all TagName to match Name and it mapped nicely