我可以使用索引作为RavenDB中索引的源吗
我试图在RavenDb中定义一个索引,它使用另一个索引的输出作为输入,但我无法让它工作。 我定义了以下实体和索引 SquadIndex生成我期望的结果,但SquadSizeIndex似乎甚至没有执行 我是否做错了什么,或者这不受支持我可以使用索引作为RavenDB中索引的源吗,ravendb,Ravendb,我试图在RavenDb中定义一个索引,它使用另一个索引的输出作为输入,但我无法让它工作。 我定义了以下实体和索引 SquadIndex生成我期望的结果,但SquadSizeIndex似乎甚至没有执行 我是否做错了什么,或者这不受支持 class Country { public string Id { get; private set; } public string Name { get; set; } } class Player { public string I
class Country
{
public string Id { get; private set; }
public string Name { get; set; }
}
class Player
{
public string Id { get; private set; }
public string Name { get; set; }
public string CountryId { get; set; }
}
class Reference
{
public string Id { get; set; }
public string Name { get; set; }
}
class SquadIndex : AbstractIndexCreationTask<Player, SquadIndex.Result>
{
public SquadIndex()
{
Map = players => from player in players
let country = LoadDocument<Country>(player.CountryId)
select new Result
{
Country = new Reference
{
Id = country.Id,
Name = country.Name
},
Players = new[]
{
new Reference
{
Id = player.Id,
Name = player.Name
}
}
};
Reduce = results => from result in results
group result by result.Country
into g
select new Result
{
Country = g.Key,
Players = g.SelectMany(x => x.Players)
};
}
internal class Result
{
public Reference Country { get; set; }
public IEnumerable<Reference> Players { get; set; }
}
}
class SquadSizeIndex : AbstractIndexCreationTask<SquadIndex.Result, SquadSizeIndex.Result>
{
public SquadSizeIndex()
{
Map = squads => from squad in squads
select new Result
{
Country = squad.Country,
PlayerCount = squad.Players.Count()
};
Reduce = results => from result in results
group result by result.Country
into g
select new Result
{
Country = g.Key,
PlayerCount = g.Sum(x => x.PlayerCount)
};
}
internal class Result
{
public Reference Country { get; set; }
public int PlayerCount { get; set; }
}
}
不,你不能。索引的输出不是要编制索引的文档。 您可以使用脚本索引结果来链接索引,但这并不简单