0
私は、クエリのインデックスを作成したい、これらの項目の統計情報と一緒にオーディオ項目のリストを表示するには、TotalDownloads & TotalPlaysです。ここでMultiMap/Reduce - Counts = 0?
は私の関連ドキュメント以下のとおりです。しかし、私のTotalDownloads
& TotalPlays
は、そこにデータがあるはずにもかかわらず、常に0です
public class AudioWithCounters : AbstractMultiMapIndexCreationTask<AudioWithCounters.AudioViewModel>
{
public class AudioViewModel
{
public string Id { get; set; }
public string ArtistName { get; set; }
public string Name { get; set; }
public int TotalDownloads { get; set; }
public int TotalPlays { get; set; }
}
public AudioWithCounters()
{
AddMap<Audio>(audios => from audio in audios
select new
{
Id = audio.Id,
ArtistName = audio.ArtistName,
Name = audio.Name,
TotalDownloads = 0,
TotalPlays = 0
});
AddMap<AudioCounter>(counters => from counter in counters
where counter.Type == Core.Enums.Audio.AudioCounterType.Download
select new
{
Id = counter.AudioId,
ArtistName = (string)null,
Name = (string)null,
TotalDownloads = 1,
TotalPlays = 0
});
AddMap<AudioCounter>(counters => from counter in counters
where counter.Type == Core.Enums.Audio.AudioCounterType.Download
select new
{
Id = counter.AudioId,
ArtistName = (string)null,
Name = (string)null,
TotalDownloads = 0,
TotalPlays = 1
});
Reduce = results => from result in results
group result by result.Id
into g
select new
{
Id = g.Key,
ArtistName = g.Select(x => x.ArtistName).Where(x => x != null).First(),
Name = g.Select(x => x.Name).Where(x => x != null).First(),
TotalDownloads = g.Sum(x => x.TotalDownloads),
TotalPlays = g.Sum(x => x.TotalPlays)
};
}
}
:ここ
Audio
- Id
- ArtistName
- Name
AudioCounter
- AudioId
- Type
- DateTime
私の現在のインデックスです。私は間違って何をしていますか?
ありがとう、それはそれほど簡単な修正だとは信じられません。これで何時間も私の髪を引っ張っていた! –