Пример #1
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);
                        }
                    }
                }
            });
        }
Пример #2
0
        public virtual void Reindex(int itemID, bool affectsChildren)
        {
            var itemX = persister.Get(itemID);

            if (itemX == null)
            {
                return;
            }

            string            title    = itemX.Title;
            string            itemType = itemX.GetType().Name;
            IndexableDocument document = null;

            if (indexer.IsIndexable(itemX))
            {
                document = indexer.CreateDocument(itemX);
            }

            Execute(new Work
            {
                Name   = "Reindex #" + itemID + "[" + itemType + "]" + "(affectsChildren = " + affectsChildren + ")",
                Action = () =>
                {
                    // update the index
                    if (document != null)
                    {
                        currentWork = "Indexing: [" + itemType + "] " + " #" + itemID + " " + title;
                        indexer.Update(document);
                    }
                    else
                    {
                        currentWork = "Skipping: [" + itemType + "] " + " #" + itemID + " " + title;
                    }

                    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);
                        }
                    }
                }
            });
        }
        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
            });
        }
Пример #4
0
        public void Title()
        {
            var item = CreateOneItem <PersistableItem>(2, "Hello world", root);

            indexer.Update(item);

            var hits = searcher.Search(Query.For("hello"));

            Assert.That(hits.Hits.Count(), Is.EqualTo(1));
        }