Skip to content

Instantly share code, notes, and snippets.

@phinett
Created March 9, 2012 17:43
Show Gist options
  • Save phinett/2007710 to your computer and use it in GitHub Desktop.
Save phinett/2007710 to your computer and use it in GitHub Desktop.
Stale Index Issue
public Audio_Index()
{
// audio properties
Map = audios => from audio in audios
select new
{
Id = audio.Id,
AudioId = audio.Id,
AccountId = audio.AccountId,
ArtistName = audio.ArtistName,
AudioType = audio.AudioType,
Identifier = audio.Identifier,
Name = audio.Name,
Status = audio.Status,
Visible = audio.Visible,
Tags = audio.Tags,
Genre_Code = audio.Genre.Code,
DateAdded = audio.DateAdded,
WeeksDownloads = audio.WeeksDownloads,
WeeksPlays = audio.WeeksPlays,
WeeksFavourites = audio.WeeksFavourites,
WeeksLikes = audio.WeeksLikes,
WeeksComments = audio.WeeksComments,
TotalDownloads = audio.TotalDownloads,
TotalPlays = audio.TotalPlays,
TotalFavourites = audio.TotalFavourites,
TotalLikes = audio.TotalLikes,
TotalComments = audio.TotalComments,
NhibernateAudioId = audio.NhibernateAudioId
};
//Sort(x => x.TotalPlays, SortOptions.Int);
//Sort(x => x.TotalDownloads, SortOptions.Int);
//Sort(x => x.TotalComments, SortOptions.Int);
//Sort(x => x.TotalFavourites, SortOptions.Int);
//Sort(x => x.TotalLikes, SortOptions.Int);
//Sort(x => x.WeeksPlays, SortOptions.Int);
//Sort(x => x.WeeksDownloads, SortOptions.Int);
//Sort(x => x.WeeksComments, SortOptions.Int);
//Sort(x => x.WeeksFavourites, SortOptions.Int);
//Sort(x => x.WeeksLikes, SortOptions.Int);
//Analyzers.Add(x => x.Name, "SimpleAnalyzer");
}
public class Tag_Count : AbstractIndexCreationTask<Audio, Tag_Count.ReduceResult>
{
public class ReduceResult
{
public string Name { get; set; }
public int Count { get; set; }
}
public Tag_Count()
{
Map = audios => from audio in audios
from tag in audio.Tags
select new { Name = tag.ToString().ToLower(), Count = 1 };
Reduce = results => from tagCount in results
group tagCount by tagCount.Name
into g
select new { Name = g.Key, Count = g.Sum(x => x.Count) };
//Sort(x => x.Count, SortOptions.Int);
//Analyzers.Add(x => x.Name, "SimpleAnalyzer");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment