/// <summary> /// Indexes the document. /// </summary> /// <param name="id">The identifier.</param> public void IndexDocument(int id) { var eventItemEntity = new EventItemService(new RockContext()).Get(id); // Check to ensure that the event item is on a calendar that is indexed if (eventItemEntity != null && eventItemEntity.EventCalendarItems.Any(c => c.EventCalendar.IsIndexEnabled)) { var indexItem = EventItemIndex.LoadByModel(eventItemEntity); IndexContainer.IndexDocument(indexItem); } }
/// <summary> /// Bulks the index documents. /// </summary> /// <exception cref="System.NotImplementedException"></exception> public void BulkIndexDocuments() { var indexableItems = new List <IndexModelBase>(); var eventItems = new EventItemService(new RockContext()) .GetIndexableActiveItems() .Include(i => i.EventItemAudiences) .Include(i => i.EventItemOccurrences) .Include(i => i.EventItemOccurrences.Select(s => s.Schedule)) .Include(i => i.EventCalendarItems.Select(c => c.EventCalendar)) .AsNoTracking() .ToList(); int recordCounter = 0; foreach (var eventItem in eventItems) { var indexableEventItem = EventItemIndex.LoadByModel(eventItem); if (indexableEventItem.IsNotNull()) { indexableItems.Add(indexableEventItem); } recordCounter++; if (recordCounter > 100) { IndexContainer.IndexDocuments(indexableItems); indexableItems = new List <IndexModelBase>(); recordCounter = 0; } } IndexContainer.IndexDocuments(indexableItems); }