/// <summary> /// Adds custom fields to internal index. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void UmbracoExamineEvents_GatheringNodeData(object sender, IndexingNodeDataEventArgs e) { if (e.Fields["nodeTypeAlias"] == "uBlogsyPost") { // add path e.Fields.Add(uBlogsy.BusinessLogic.Constants.Examine.uBlogsySearchablePath, e.Fields["path"].Replace(",", " ")); // get value var date = ExamineIndexHelper.GetValueFromFieldOrProperty(e, uBlogsy.BusinessLogic.Constants.Examine.uBlogsySearchableMonth, "uBlogsyPostDate"); // year e.Fields.Add(uBlogsy.BusinessLogic.Constants.Examine.uBlogsySearchableYear, DateTime.Parse(date).Year.ToString()); // month e.Fields.Add(uBlogsy.BusinessLogic.Constants.Examine.uBlogsySearchableMonth, DateTime.Parse(date).Month.ToString()); // day e.Fields.Add(uBlogsy.BusinessLogic.Constants.Examine.uBlogsySearchableDay, DateTime.Parse(date).Day.ToString()); // label ExamineIndexHelper.AddIndexByPropertyInSelectedNodes(e, uBlogsy.BusinessLogic.Constants.Examine.uBlogsySearchableLabels, "uBlogsyPostLabels", "uBlogsyLabelName"); ExamineIndexHelper.AddIdsFromCsvProperty(e, uBlogsy.BusinessLogic.Constants.Examine.uBlogsySearchableLabelIds, "uBlogsyPostLabels"); // author name ExamineIndexHelper.AddIndexByPropertyInSelectedNodes(e, uBlogsy.BusinessLogic.Constants.Examine.uBlogsySearchableAuthor, "uBlogsyPostAuthor", "uBlogsyAuthorName"); ExamineIndexHelper.AddIdsFromCsvProperty(e, uBlogsy.BusinessLogic.Constants.Examine.uBlogsySearchableAuthorIds, "uBlogsyPostAuthor"); // tags ExamineIndexHelper.AddIndexByPropertyInSelectedNodes(e, uBlogsy.BusinessLogic.Constants.Examine.uBlogsySearchableTags, "uBlogsyPostTags", "uTagsyTagName"); ExamineIndexHelper.AddIdsFromCsvProperty(e, uBlogsy.BusinessLogic.Constants.Examine.uBlogsySearchableTagIds, "uBlogsyPostTags"); } }
private void IndexProviderTransformingIndexValues(object sender, IndexingItemEventArgs e) { if (e.ValueSet.Category == "content") { e.ValueSet.TryAdd("searchablePath", e.ValueSet.GetValue("path").ToString().Replace(",", " ")); var combinedFields = new StringBuilder(); foreach (var fieldValues in e.ValueSet.Values) { foreach (var value in fieldValues.Value) { if (value != null) { combinedFields.AppendLine(value.ToString()); } } } e.ValueSet.TryAdd("combinedField", combinedFields.ToString()); if (e.ValueSet.ItemType == USNConstants.BlogPostAlias) { // add path e.ValueSet.TryAdd(USNConstants.BlogSearchablePath, e.ValueSet.GetValue("path").ToString().Replace(",", " ")); // get the news item date var postDate = ExamineIndexHelper.GetValueFromFieldOrProperty(e, USNConstants.BlogSearchableDate, USNConstants.BlogPostDateFieldAlias, _umbracoContextFactory); // date e.ValueSet.TryAdd(USNConstants.BlogSearchableDate, DateTime.Parse(postDate).Ticks); // year e.ValueSet.TryAdd(USNConstants.BlogSearchableDate_Year, DateTime.Parse(postDate).Year.ToString()); // month e.ValueSet.TryAdd(USNConstants.BlogSearchableDate_Month, DateTime.Parse(postDate).Month.ToString()); // day e.ValueSet.TryAdd(USNConstants.BlogSearchableDate_Day, DateTime.Parse(postDate).Day.ToString()); // categories ExamineIndexHelper.AddIdsFromCsvUdiProperty(e, USNConstants.BlogSearchableCategoryIds, USNConstants.BlogCategoryFieldAlias, _umbracoContextFactory); } } }