Beispiel #1
0
        public virtual void Update(IndexableDocument document)
        {
            logger.Debug("Updating item #" + document.ID);

            var doc = new Document();
            foreach (var field in document.Values)
                doc.Add(new Field(field.Name, field.Value, field.Stored ? Field.Store.YES : Field.Store.NO, field.Analyzed ? Field.Index.ANALYZED : Field.Index.NOT_ANALYZED));

            WriteToIndex(document.ID, doc);
        }
Beispiel #2
0
        /// <summary>Creates a document that can be indexed.</summary>
        /// <param name="item">The item containing values to be indexed.</param>
        /// <returns>A document that can be passed to the Update method to be indexed.</returns>
        public virtual IndexableDocument CreateDocument(ContentItem item)
        {
            var doc = new IndexableDocument();

            doc.ID = item.ID;

            doc.Add(Properties.ID, item.ID.ToString(), store: true, analyze: false);
            doc.Add(Properties.Title, item.Title, store: true, analyze: true);
            doc.Add(Properties.Name, item.Name, store: true, analyze: false);
            doc.Add(Properties.SavedBy, item.SavedBy, store: true, analyze: false);
            doc.Add(Properties.Created, item.Created, store: true, analyze: false);
            doc.Add(Properties.Updated, item.Updated, store: true, analyze: false);
            doc.Add(Properties.Published, item.Published, store: true, analyze: false);
            doc.Add(Properties.Expires, item.Expires, store: true, analyze: false);
            if (item.IsPage && item.State != ContentState.Deleted)
            {
                try
                {
                    doc.Add(Properties.Url, item.Url, store: true, analyze: false);
                }
                catch (TemplateNotFoundException ex)
                {
                    logger.Warn("Failed to retrieve Url on " + item, ex);
                    return(null);
                }
            }
            doc.Add(Properties.Path, item.Path, store: true, analyze: false);
            doc.Add(Properties.AncestralTrail, item.AncestralTrail, store: true, analyze: false);
            doc.Add(Properties.Trail, Utility.GetTrail(item), store: true, analyze: false);
            doc.Add(Properties.AlteredPermissions, (int)item.AlteredPermissions, store: true, analyze: false);
            doc.Add(Properties.State, (int)item.State, store: true, analyze: false);
            doc.Add(Properties.IsPage, item.IsPage.ToString().ToLower(), store: true, analyze: false);
            doc.Add(Properties.Roles, GetRoles(item), store: true, analyze: true);
            doc.Add(Properties.Types, GetTypes(item), store: true, analyze: true);
            doc.Add(Properties.Language, GetLanguage(item), store: true, analyze: false);
            doc.Add(Properties.Visible, item.Visible.ToString().ToLower(), store: true, analyze: false);
            doc.Add(Properties.SortOrder, item.SortOrder, store: true, analyze: false);

            var texts = Extract(item);

            foreach (var t in texts)
            {
                doc.Add("Detail." + t.Name, t.Value, store: t.Stored, analyze: t.Analyzed);
            }

            doc.Add("Text", Join(texts), store: false, analyze: true);

            using (var sw = new StringWriter())
            {
                AppendPartsRecursive(item, sw);
                doc.Add("PartsText", sw.ToString(), store: false, analyze: true);
            }

            return(doc);
        }
Beispiel #3
0
        public virtual void Update(IndexableDocument document)
        {
            logger.Debug("Updating item #" + document.ID);

            var doc = new Document();

            foreach (var field in document.Values)
            {
                doc.Add(new Field(field.Name, field.Value, field.Stored ? Field.Store.YES : Field.Store.NO, field.Analyzed ? Field.Index.ANALYZED : Field.Index.NOT_ANALYZED));
            }

            WriteToIndex(document.ID, doc);
        }
		/// <summary>Creates a document that can be indexed.</summary>
		/// <param name="item">The item containing values to be indexed.</param>
		/// <returns>A document that can be passed to the Update method to be indexed.</returns>
		public virtual IndexableDocument CreateDocument(ContentItem item)
		{
			var doc = new IndexableDocument();
			doc.ID = item.ID;

			doc.Add(Properties.ID, item.ID.ToString(), store: true, analyze: false);
			doc.Add(Properties.Title, item.Title, store: true, analyze: true);
			doc.Add(Properties.Name, item.Name, store: true, analyze: false);
			doc.Add(Properties.SavedBy, item.SavedBy, store: true, analyze: false);
			doc.Add(Properties.Created, item.Created, store: true, analyze: false);
			doc.Add(Properties.Updated, item.Updated, store: true, analyze: false);
			doc.Add(Properties.Published, item.Published, store: true, analyze: false);
			doc.Add(Properties.Expires, item.Expires, store: true, analyze: false);
			if (item.IsPage && item.State != ContentState.Deleted)
			{
				try
				{
					doc.Add(Properties.Url, item.Url, store: true, analyze: false);
				}
				catch (TemplateNotFoundException ex)
				{
					logger.Warn("Failed to retrieve Url on " + item, ex);
					return null;
				}
			}
			doc.Add(Properties.Path, item.Path, store: true, analyze: false);
			doc.Add(Properties.AncestralTrail, item.AncestralTrail, store: true, analyze: false);
			doc.Add(Properties.Trail, Utility.GetTrail(item), store: true, analyze: false);
			doc.Add(Properties.AlteredPermissions, (int)item.AlteredPermissions, store: true, analyze: false);
			doc.Add(Properties.State, (int)item.State, store: true, analyze: false);
			doc.Add(Properties.IsPage, item.IsPage.ToString().ToLower(), store: true, analyze: false);
			doc.Add(Properties.Roles, GetRoles(item), store: true, analyze: true);
			doc.Add(Properties.Types, GetTypes(item), store: true, analyze: true);
			doc.Add(Properties.Language, GetLanguage(item), store: true, analyze: false);
			doc.Add(Properties.Visible, item.Visible.ToString().ToLower(), store: true, analyze: false);
			doc.Add(Properties.SortOrder, item.SortOrder, store: true, analyze: false);

			var texts = Extract(item);
			foreach (var t in texts)
				doc.Add("Detail." + t.Name, t.Value, store: t.Stored, analyze: t.Analyzed);
			
			doc.Add("Text", Join(texts), store: false, analyze: true);

			using (var sw = new StringWriter())
			{
				AppendPartsRecursive(item, sw);
				doc.Add("PartsText", sw.ToString(), store: false, analyze: true);
			}

			return doc;
		}
        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 void Update(IndexableDocument document)
		{
			Request("PUT",  instanceName + "/" + document.ID, new JavaScriptSerializer().Serialize(document));
		}
Beispiel #7
0
 public void Update(IndexableDocument document)
 {
 }
Beispiel #8
0
 public void Update(IndexableDocument document)
 {
     indexer.Update(document);
 }
Beispiel #9
0
		public void Update(IndexableDocument document)
		{
		}
		public void Update(IndexableDocument document)
		{
			indexer.Update(document);
		}