Ejemplo n.º 1
0
        public virtual void ReindexDescendants(ContentItem root, bool clearBeforeReindex)
        {
            DoWork(() =>
            {
                if (clearBeforeReindex)
                {
                    indexer.Delete(root.ID);
                }

                root = persister.Get(root.ID);
                indexer.Update(root);
                ReindexChildren(root.ID);
            });
        }
Ejemplo n.º 2
0
        public JsonResult UpdateItem(string id, bool recursive = false)
        {
            try
            {
                if (_contentLoader.TryGet(ContentReference.Parse(id), out IContent content))
                {
                    string indexName = null;

                    // Point catalog content to correct index
                    if (Constants.CommerceProviderName.Equals(content.ContentLink.ProviderName))
                    {
                        string lang = _indexer.GetLanguage(content);
                        indexName = _settings.GetCustomIndexName($"{_settings.Index}-{Constants.CommerceProviderName}", lang);
                    }

                    IndexingStatus status = recursive
                        ? _indexer.UpdateStructure(content, indexName)
                        : _indexer.Update(content, indexName);

                    return(Json(new { status = status.ToString() }));
                }
            }
            catch (Exception ex)
            {
                Logger.Error("Error updating item with id '" + id + "'", ex);
                return(Json(new { status = nameof(IndexingStatus.Error), error = ex.Message }));
            }

            return(Json(new { status = nameof(IndexingStatus.Error) }));
        }
Ejemplo n.º 3
0
        public virtual void Reindex(int itemID, bool affectsChildren)
        {
            var itemX = persister.Get(itemID);

            if (itemX == null)
            {
                return;
            }

            string title    = itemX.Title;
            var    document = indexer.CreateDocument(itemX);

            Execute(new Work
            {
                Name   = "Reindex #" + itemID + " (affectsChildren = " + affectsChildren + ")",
                Action = () =>
                {
                    // update the index
                    currentWork = "Indexing " + title + " #" + itemID;
                    indexer.Update(document);

                    if (affectsChildren)
                    {
                        var reindexIds = persister.Repository
                                         .Select(Parameter.Equal("Parent.ID", itemID), "ID")
                                         .Select(d => d["ID"]).Cast <int>().ToList();

                        foreach (var childId in reindexIds)
                        {
                            Reindex(childId, affectsChildren);
                        }
                    }
                }
            });
        }
Ejemplo n.º 4
0
        internal static void UpdateIndex(object sender, ContentSecurityEventArg e)
        {
            Logger.Debug($"ACL changed for '{e.ContentLink}'");

            var published = VersionRepository.LoadPublished(e.ContentLink);

            if (published == null)
            {
                Logger.Debug("Previously unpublished, do nothing");
                return;
            }

            if (ContentLoader.TryGet(e.ContentLink, out IContent content))
            {
                Logger.Debug("Valid content, update index");
                EPiIndexer.Update(content);
            }
        }
        internal static void UpdateIndex(object sender, ContentEventArgs e)
        {
            if (ContentReference.WasteBasket.CompareToIgnoreWorkID(e.TargetLink))
            {
                DeleteFromIndex(sender, e);
                return;
            }

            Logger.Debug($"Raising event UpdateIndex for '{e.Content.ContentLink}'");

            EPiIndexer.Update(e.Content);
        }
Ejemplo n.º 6
0
        private void IndexerWorkerLoop()
        {
            const int IndexerPollIntervalMilliseconds = 5000;

            while (true)
            {
                try
                {
                    _indexer.Update();
                }
                // Swallow any exceptions from the background thread to avoid killing the worker
                // process. We should only get here if logging failed for indexer exceptions.
                catch (Exception) { }

                Thread.Sleep(IndexerPollIntervalMilliseconds);
            }
        }
Ejemplo n.º 7
0
        public override MigrationResult Migrate(DatabaseStatus preSchemaUpdateStatus)
        {
            indexer.Clear();

            int count = 0;

            foreach (var item in repository.Find("VersionOf.ID", null))
            {
                indexer.Update(item);
                count++;
            }

            return(new MigrationResult(this)
            {
                UpdatedItems = count
            });
        }
Ejemplo n.º 8
0
        public async Task Handle(PodcastCreatedEvent evnt)
        {
            var id = evnt.Id;

            var result = await _queryDispatcher.Request <GetPodcastQuery, GetPodcastQueryResult>(new GetPodcastQuery { Id = id });

            var podcast = result.Podcast;

            var podcastDocument = new PodcastDocument
            {
                Id       = podcast.Id.ToString(),
                Title    = podcast.Title,
                Category = podcast.CategoryName,
                Tags     = podcast.Tags
            };

            await _indexer.Update(podcastDocument);
        }
Ejemplo n.º 9
0
 public void Update(IndexableDocument document)
 {
     indexer.Update(document);
 }