我的问题很短,我坚持下去。我有一系列文件,例如:
{
...,
"Type": [
"Type1",
"Type2",
"Type3",
"Type4"
],
...
}
而且我认为我需要创建一个 map/reduce 索引来将这些值分组到一个字符串列表中,例如,如果我有这两个文档:
{
...,
"Type": [
"Type1",
"Type3"
],
...
}
{
...
"Type": [
"Type2",
"Type3",
"Type4"
],
...
}
我需要一个包含所有不同值的列表的结果,例如 {"Type1","Type2","Type3","Type4"}
我不知道该怎么做,我尝试了几种方法,但没有成功。
我忘了说,我有大量的数据,像现在1500多个文档
public class ProjectTypeIndex : AbstractIndexCreationTask<Project, ProjectTypeIndex.ReduceResult>
{
public class ReduceResult
{
public string ProjectType { get; set; }
}
public ProjectTypeIndex()
{
Map = projects => from project in projects
select new
{
project.Type
};
Reduce = results => from result in results
group result by result.Type into g
select new
{
ProjectType = g.Key
};
}
}