internal JObject GetIndexData(IIndexable indexable, IProviderUpdateContext context)
        {
            Assert.ArgumentNotNull(indexable, "indexable");
            Assert.ArgumentNotNull(context, "context");

            var options = _index.Configuration.DocumentOptions;

            Assert.Required(options, "IDocumentBuilderOptions of wrong type for this crawler");
            if (indexable.Id.ToString() == string.Empty)
            {
                return(new JObject());
            }
            var documentBuilder = CreateDocumentBuilder(indexable, context);

            AssignCustomOptions(_index.Configuration as IIndexCustomOptions, documentBuilder as IIndexCustomOptions);

            documentBuilder.AddSpecialFields();
            documentBuilder.AddItemFields();
            documentBuilder.AddComputedIndexFields();
            //Sitecore8 does not implement this
            //documentBuilder.AddProviderCustomFields();
            documentBuilder.AddBoost();

            var algoliaDocumentBuilder = documentBuilder as AlgoliaDocumentBuilder;

            algoliaDocumentBuilder?.GenerateTags();

            return(documentBuilder.Document);
        }
        public override void Rebuild(IndexingOptions indexingOptions)
        {
            //TODO:  Build the Azure Index
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            BuildAzureIndex();

            using (IProviderUpdateContext updateContext = CreateUpdateContext())
            {
                foreach (var crawler in this.Crawlers)
                {
                    crawler.RebuildFromRoot(updateContext, indexingOptions, CancellationToken.None);
                }

                if ((this.IndexingState & IndexingState.Stopped) != IndexingState.Stopped)
                {
                    updateContext.Optimize();
                }

                updateContext.Commit();
                updateContext.Optimize();
                stopwatch.Stop();

                if ((this.IndexingState & IndexingState.Stopped) == IndexingState.Stopped)
                {
                    return;
                }

                this.PropertyStore.Set(IndexProperties.RebuildTime, stopwatch.ElapsedMilliseconds.ToString((IFormatProvider)CultureInfo.InvariantCulture));
            }
        }
Ejemplo n.º 3
0
        internal IndexData GetIndexData(IIndexable indexable, IProviderUpdateContext context)
        {
            Assert.ArgumentNotNull(indexable, "indexable");
            Assert.ArgumentNotNull(context, "context");
            Assert.Required((index.Configuration.DocumentOptions as AzureDocumentBuilderOptions), "IDocumentBuilderOptions of wrong type for this crawler");
            AzureDocumentBuilder documentBuilder = (AzureDocumentBuilder)ReflectionUtil.CreateObject(context.Index.Configuration.DocumentBuilderType, new object[2]
            {
                indexable,
                context
            });

            if (documentBuilder == null)
            {
                CrawlingLog.Log.Error("Unable to create document builder (" + context.Index.Configuration.DocumentBuilderType + "). Please check your configuration. We will fallback to the default for now.", (Exception)null);
                documentBuilder = new AzureDocumentBuilder(indexable, context);
            }
            documentBuilder.AddSpecialFields();
            documentBuilder.AddItemFields();
            documentBuilder.AddComputedIndexFields();
            documentBuilder.AddBoost();
            var indexData = new IndexData(index, indexable, documentBuilder);

            index.AzureSchema.AddAzureIndexFields(indexData.Fields.Where(f => f.Name != indexData.UpdateTerm.Name).ToList());
            index.AzureSchema.BuildAzureIndexSchema(indexData.UpdateTerm, indexData.FullUpdateTerm);
            return(indexData);
        }
Ejemplo n.º 4
0
        protected override void PerformRebuild(IndexingOptions indexingOptions, CancellationToken cancellationToken)
        {
            CrawlingLog.Log.Debug($"{LogPreffix} {Name} PerformRebuild()");

#if (SITECORE8)
            CrawlingLog.Log.Debug($"PerformRebuild - Disposed - {isDisposed}", null);
            CrawlingLog.Log.Debug($"PerformRebuild - Initialized - {initialized}", null);
#endif

            if (!base.ShouldStartIndexing(indexingOptions))
            {
                return;
            }
            lock (this.GetFullRebuildLockObject())
            {
                using (IProviderUpdateContext providerUpdateContext = this.CreateFullRebuildContext())
                {
                    CrawlingLog.Log.Warn($"[Index={this.Name}] Reset Started", null);
                    this.DoReset(providerUpdateContext);
                    CrawlingLog.Log.Warn($"[Index={this.Name}] Reset Ended", null);
                    CrawlingLog.Log.Warn($"[Index={this.Name}] Full Rebuild Started", null);
                    this.DoRebuild(providerUpdateContext, indexingOptions, cancellationToken);
                    CrawlingLog.Log.Warn($"[Index={this.Name}] Full Rebuild Ended", null);
                }
            }
        }
Ejemplo n.º 5
0
        public void Add(IIndexable indexable, IProviderUpdateContext context, ProviderIndexConfiguration indexConfiguration)
        {
            Assert.ArgumentNotNull(indexable, "indexable");
            Assert.ArgumentNotNull(context, "context");
            Assert.ArgumentNotNull(indexConfiguration, "indexConfiguration");

            Item item = indexable as SitecoreIndexableItem;

            if (item == null)
            {
                return;                 //log or assert this
            }
            if (context.IsParallel)
            {
                Action <Language> body = language => ProcessLanguageItem((SitecoreIndexableItem)item, language, context);
                Parallel.ForEach(item.Languages, context.ParallelOptions, body);
            }
            else
            {
                foreach (var language in item.Languages)
                {
                    ProcessLanguageItem((SitecoreIndexableItem)item, language, context);
                }
            }
        }
        protected override void UpdateItemVersion(IProviderUpdateContext context, Item version, IndexEntryOperationContext operationContext)
        {
            IIndexable indexableItem = GetIndexable(version);

            this.Operations.Update((IIndexable)indexableItem, context, context.Index.Configuration);
            this.UpdateLanguageFallbackDependentItems(context, (SitecoreIndexableItem)indexableItem, operationContext);
        }
        protected override void PerformRebuild(IndexingOptions indexingOptions, CancellationToken cancellationToken)
        {
            EnsureInitialized();
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            AzureServiceClient.Indexes.Delete(this.Name);
            AzureSchema.AzureSchemaBuilt = false;

            using (IProviderUpdateContext updateContext = CreateUpdateContext())
            {
                foreach (var crawler in this.Crawlers)
                {
                    crawler.RebuildFromRoot(updateContext, indexingOptions, CancellationToken.None);
                }

                if ((this.IndexingState & IndexingState.Stopped) != IndexingState.Stopped)
                {
                    updateContext.Optimize();
                }

                updateContext.Commit();
                updateContext.Optimize();
                stopwatch.Stop();

                if ((this.IndexingState & IndexingState.Stopped) == IndexingState.Stopped)
                {
                    return;
                }

                this.PropertyStore.Set(IndexProperties.RebuildTime, stopwatch.ElapsedMilliseconds.ToString((IFormatProvider)CultureInfo.InvariantCulture));
            }
        }
Ejemplo n.º 8
0
        protected virtual void DoReset(IProviderUpdateContext context)
        {
            var result = _repository.ClearIndexAsync().Result;

            var taskId = result["taskID"].ToString();

            _repository.WaitTaskAsync(taskId).Wait();
        }
 public LuceneSpatialDocumentBuilder(IIndexable indexable, IProviderUpdateContext context)
     : base(indexable, context)
 {
     if (spatialConfigurations == null)
     {
         BuildSettings();
     }
 }
Ejemplo n.º 10
0
 public LuceneSpatialDocumentBuilder(IIndexable indexable, IProviderUpdateContext context)
     : base(indexable, context)
 {
     if (spatialConfigurations == null)
     {
         BuildSettings();
     }
 }
Ejemplo n.º 11
0
        protected virtual void UpdateItemVersion(IProviderUpdateContext context, Item version, IndexEntryOperationContext operationContext)
        {
            var versionIndexable = PrepareIndexableVersion(version, context);

            Operations.Update(versionIndexable, context, context.Index.Configuration);
            UpdateClones(context, versionIndexable);
            UpdateLanguageFallbackDependentItems(context, versionIndexable, operationContext);
        }
Ejemplo n.º 12
0
        internal SitecoreIndexableItem PrepareIndexableVersion(Item item, IProviderUpdateContext context)
        {
            var sitecoreIndexableItem = (SitecoreIndexableItem)item;

            ((IIndexableBuiltinFields)sitecoreIndexableItem).IsLatestVersion = item.Versions.IsLatestVersion();
            sitecoreIndexableItem.IndexFieldStorageValueFormatter            = context.Index.Configuration.IndexFieldStorageValueFormatter;
            return(sitecoreIndexableItem);
        }
        public AlgoliaDocumentBuilder(IIndexable indexable, IProviderUpdateContext context) : base(indexable, context)
        {
            var config = context.Index.Configuration as AlgoliaIndexConfiguration;

            if (config != null)
            {
                _tagsProcessor = config.TagsProcessor;
            }
        }
        public void Add(IIndexable indexable, IProviderUpdateContext context, ProviderIndexConfiguration indexConfiguration)
        {
            //if (doc == null)
            //{
            //    Event.RaiseEvent("indexing:excludedfromindex", new object[] { _index.Name, indexable.Id });
            //    return;
            //}

            //context.AddDocument(doc, null);
        }
        public void Delete(IIndexableId id, IProviderUpdateContext context)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }

            CrawlingLog.Log.Debug($"{LogPreffix} {_index.Name} Delete IIndexableId {id.Value}");
            context.Delete(id);
        }
        public void Update(IIndexable indexable, IProviderUpdateContext context, ProviderIndexConfiguration indexConfiguration)
        {
            var data = BuildDataToIndex(context, indexable);
            if (data == null)
                return;
            if (data.IsEmpty)
                CrawlingLog.Log.Warn(string.Format("AzureIndexOperations.Update(): IndexVersion produced a NULL doc for UniqueId {0}. Skipping.", indexable.UniqueId), null);

            var document = data.BuildDocument();
            LogIndexOperation(() => string.Format("Updating indexable UniqueId:{0}, Culture:{1}, DataSource:{2}, Index:{3}", indexable.UniqueId, indexable.Culture, indexable.DataSource, context.Index.Name), data, document);
            context.UpdateDocument(document, data.UpdateTerm, data.Culture != null ? new CultureExecutionContext(data.Culture) : null);
        }
Ejemplo n.º 17
0
        public override void Update(IProviderUpdateContext context, IIndexableUniqueId indexableUniqueId, IndexEntryOperationContext operationContext, IndexingOptions indexingOptions = IndexingOptions.Default)
        {
            Assert.ArgumentNotNull(indexableUniqueId, "indexableUniqueId");

            if (!ShouldStartIndexing(indexingOptions))
            {
                return;
            }

            if (IsExcludedFromIndex(indexableUniqueId, true))
            {
                return;
            }

            if (operationContext != null)
            {
                if (operationContext.NeedUpdateChildren)
                {
                    var obj = Sitecore.Data.Database.GetItem((indexableUniqueId as SitecoreItemUniqueId));
                    if (obj != null)
                    {
                        UpdateHierarchicalRecursive(context, obj, CancellationToken.None);
                        return;
                    }
                }

                if (operationContext.NeedUpdatePreviousVersion)
                {
                    var obj = Sitecore.Data.Database.GetItem((indexableUniqueId as SitecoreItemUniqueId));
                    if (obj != null)
                    {
                        UpdatePreviousVersion(obj, context);
                    }
                }
            }
            var indexableAndCheckDeletes = GetIndexableAndCheckDeletes(indexableUniqueId);

            if (indexableAndCheckDeletes == null)
            {
                if (GroupShouldBeDeleted(indexableUniqueId.GroupId))
                {
                    Delete(context, indexableUniqueId.GroupId, IndexingOptions.Default);
                }
                else
                {
                    Delete(context, indexableUniqueId, IndexingOptions.Default);
                }
            }
            else
            {
                DoUpdate(context, indexableAndCheckDeletes, operationContext);
            }
        }
        public void Update(IIndexable indexable, IProviderUpdateContext context, ProviderIndexConfiguration indexConfiguration)
        {
            var doc = GetAzureSearchItem(indexable);

            //if (doc == null)
            //{
            //    Event.RaiseEvent("indexing:excludedfromindex", new object[] { index.Name, indexable.Id });
            //    return;
            //}

            context.UpdateDocument(doc, null);
        }
        public void Update(IIndexable indexable, IProviderUpdateContext context, ProviderIndexConfiguration indexConfiguration)
        {
            var doc = GetDocument(indexable, context);

            //START: post 4
            if (doc == null)
            {
                Event.RaiseEvent("indexing:excludedfromindex", new object[] { _index.Name, indexable.Id });
                return;
            }
            //END: post 4
            context.UpdateDocument(doc, null, null);
        }
        //START: part 6 (fix for ontime issue 386719)

        public XmlDocumentBuilder(IIndexable indexable, IProviderUpdateContext context) : base(indexable, context)
        {
            Assert.ArgumentNotNull(indexable, "indexable");
            Assert.ArgumentNotNull(context, "context");

            var item = (Item)(indexable as SitecoreIndexableItem);
            var tag  = new XElement("item");

            tag.SetAttributeValue("name", item.Name);
            tag.SetAttributeValue("path", item.Paths.Path);
            tag.SetAttributeValue("id", item.ID);
            this.Document.Add(tag);
        }
 public void Delete(IIndexable indexable, IProviderUpdateContext context)
 {
     Assert.ArgumentNotNull(indexable, "indexable");
     VerboseLogging.CrawlingLogDebug(() => string.Format("Deleting indexable UniqueId:{0}, Index:{1}", indexable.UniqueId, context.Index.Name));
     var providerUpdateContextEx = context as IProviderUpdateContextEx;
     if (providerUpdateContextEx != null)
         providerUpdateContextEx.Delete(indexable.UniqueId, new IExecutionContext[1]
         {
             indexable.Culture != null ? new CultureExecutionContext(indexable.Culture) : null
         });
     else
         context.Delete(indexable.UniqueId);
 }
Ejemplo n.º 22
0
        private void UpdateClones(IProviderUpdateContext context, SitecoreIndexableItem versionIndexable)
        {
            IEnumerable <Item> clones;

            using (new WriteCachesDisabler())
                clones = versionIndexable.Item.GetClones(false);
            foreach (Item clone in clones)
            {
                SitecoreIndexableItem sitecoreIndexableItem = PrepareIndexableVersion(clone, context);
                if (!IsExcludedFromIndex(clone, false))
                {
                    Operations.Update(sitecoreIndexableItem, context, context.Index.Configuration);
                }
            }
        }
Ejemplo n.º 23
0
        //TODO: Could be removed, hasn't changed from what is being overridden, just wanted to see
        public override void RebuildFromRoot(IProviderUpdateContext context, IndexingOptions indexingOptions, CancellationToken cancellationToken)
        {
            Assert.ArgumentNotNull(context, "context");
            if (!ShouldStartIndexing(indexingOptions))
            {
                return;
            }
            var indexableRoot = GetIndexableRoot();

            Assert.IsNotNull(indexableRoot, "RebuildFromRoot: Unable to retrieve root item");
            Assert.IsNotNull(DocumentOptions, "DocumentOptions");
            context.Index.Locator.GetInstance <IEvent>().RaiseEvent("indexing:addingrecursive", context.Index.Name, indexableRoot.UniqueId, indexableRoot.AbsolutePath);
            AddHierarchicalRecursive(indexableRoot, context, index.Configuration, cancellationToken);
            context.Index.Locator.GetInstance <IEvent>().RaiseEvent("indexing:addedrecursive", context.Index.Name, indexableRoot.UniqueId, indexableRoot.AbsolutePath);
        }
        protected virtual XDocument GetDocument(IIndexable indexable, IProviderUpdateContext context)
        {
            //START: post 4
            if (InboundIndexFilterPipeline.Run(new InboundIndexFilterArgs(indexable)))
            {
                return(null);
            }
            //END: post 4

            //START: commented out in post 5
            //var doc = new XDocument(
            //  new XElement("item",
            //    new XAttribute("id", item.ID.ToString()),
            //    new XAttribute("name", item.Name),
            //    new XAttribute("path", item.Paths.Path)
            //  )
            //);
            //return doc;
            //END: commented out in post 5

            //START: post 5
            var builder = new XmlDocumentBuilder(indexable, context);

            builder.AddItemFields();
            return(builder.Document);
            //END: post 5

            //var item = (Item)(indexable as SitecoreIndexableItem);
            //foreach (var language in item.Languages)
            //{
            //    var latestVersion = item.Database.GetItem(item.ID, language, Sitecore.Data.Version.Latest);
            //    if (fields != null)
            //    {
            //        fields.IsLatestVersion = fields.Version == ((SitecoreIndexableItem)latestVersion).Item.Version.Number;
            //    }
            //    if (indexable is SitecoreIndexableItem)
            //    {
            //        ((SitecoreIndexableItem)indexable).IndexFieldStorageValueFormatter = context.Index.Configuration.IndexFieldStorageValueFormatter;
            //    }
            //    builder.AddSpecialField("_uniqueid", indexable.UniqueId.Value, false);
            //    builder.AddSpecialField("_datasource", indexable.DataSource, false);
            //    builder.AddSpecialField("_indexname", _index.Name, false);
            //    builder.AddSpecialFields();
            //    builder.AddItemFields();
            //    builder.AddBoost();
            //}
            //return builder.Document;
        }
        public void Add(IIndexable indexable, IProviderUpdateContext context, ProviderIndexConfiguration indexConfiguration)
        {
            Assert.ArgumentNotNull(indexable, "indexable");
            Assert.ArgumentNotNull(context, "context");
            var data = BuildDataToIndex(context, indexable);
            if (data == null)
                return;
            if (data.IsEmpty)
                CrawlingLog.Log.Warn(string.Format("AzureIndexOperations.Add(): IndexVersion produced a NULL doc for version {0}. Skipping.", indexable.UniqueId));
            var document = data.BuildDocument();

            ((IAzureProviderIndex)context.Index).AzureSchema.ReconcileAzureIndexSchema(document);

            LogIndexOperation(() => string.Format("Adding indexable UniqueId:{0}, Culture:{1}, DataSource:{2}, Index:{3}", indexable.UniqueId, indexable.Culture, indexable.DataSource, context.Index.Name), data, document);
            context.AddDocument(document, data.Culture != null ? new CultureExecutionContext(data.Culture) : null);
        }
        public override void Delete(IIndexableId indexableId, IndexingOptions indexingOptions)
        {
            this.VerifyNotDisposed();
            if (!this.ShouldStartIndexing(indexingOptions))
            {
                return;
            }

            using (IProviderUpdateContext updateContext = this.CreateUpdateContext())
            {
                foreach (IProviderCrawler providerCrawler in this.Crawlers)
                {
                    providerCrawler.Delete(updateContext, indexableId, indexingOptions);
                }

                updateContext.Commit();
            }
        }
Ejemplo n.º 27
0
        public void Update(IIndexable indexable, IProviderUpdateContext context, ProviderIndexConfiguration indexConfiguration)
        {
            var data = BuildDataToIndex(context, indexable);

            if (data == null)
            {
                return;
            }
            if (data.IsEmpty)
            {
                CrawlingLog.Log.Warn(string.Format("AzureIndexOperations.Update(): IndexVersion produced a NULL doc for UniqueId {0}. Skipping.", indexable.UniqueId), null);
            }

            var document = data.BuildDocument();

            LogIndexOperation(() => string.Format("Updating indexable UniqueId:{0}, Culture:{1}, DataSource:{2}, Index:{3}", indexable.UniqueId, indexable.Culture, indexable.DataSource, context.Index.Name), data, document);
            context.UpdateDocument(document, data.UpdateTerm, data.Culture != null ? new CultureExecutionContext(data.Culture) : null);
        }
Ejemplo n.º 28
0
        public void Delete(IIndexable indexable, IProviderUpdateContext context)
        {
            Assert.ArgumentNotNull(indexable, "indexable");
            VerboseLogging.CrawlingLogDebug(() => string.Format("Deleting indexable UniqueId:{0}, Index:{1}", indexable.UniqueId, context.Index.Name));
            var providerUpdateContextEx = context as IProviderUpdateContextEx;

            if (providerUpdateContextEx != null)
            {
                providerUpdateContextEx.Delete(indexable.UniqueId, new IExecutionContext[1]
                {
                    indexable.Culture != null ? new CultureExecutionContext(indexable.Culture) : null
                });
            }
            else
            {
                context.Delete(indexable.UniqueId);
            }
        }
Ejemplo n.º 29
0
 private void ApplyPermissionsThenIndex(IProviderUpdateContext context, IIndexable version, IIndexable latestVersion)
 {
     if (InboundIndexFilterPipeline.Run(new InboundIndexFilterArgs(version)))
     {
         Event.RaiseEvent("indexing:excludedfromindex", new object[] { _index.Name, version.UniqueId });
     }
     else
     {
         var itemToAdd = IndexVersion(version, latestVersion, context);
         if (itemToAdd == null)
         {
             CrawlingLog.Log.Warn(string.Format("ElasticIndexOperations : AddItem : IndexVersion produced a NULL doc for version {0}. Skipping.", version.UniqueId));
         }
         else
         {
             context.AddDocument(itemToAdd, null);
         }
     }
 }
Ejemplo n.º 30
0
        protected AbstractDocumentBuilder(IIndexable indexable, IProviderUpdateContext context)
        {
            Assert.ArgumentNotNull(indexable, "indexable");
            Assert.ArgumentNotNull(context, "context");
            Options         = context.Index.Configuration.DocumentOptions;
            Indexable       = indexable;
            Index           = context.Index;
            Document        = new T();
            IsParallel      = context.IsParallel;
            ParallelOptions = context.ParallelOptions;
            var obj = (Item)(indexable as SitecoreIndexableItem);

            if (obj != null)
            {
                IsTemplate = TemplateManager.IsTemplate(obj);
                IsMedia    = obj.Paths.IsMediaItem;
            }
            Settings = Index.Locator.GetInstance <IContentSearchConfigurationSettings>();
        }
Ejemplo n.º 31
0
        private void ProcessLanguageItem(IIndexable indexable, Language language, IProviderUpdateContext context)
        {
            Item item = indexable as SitecoreIndexableItem;

            if (item == null)
            {
                return;
            }

            var latestVersion = item.Database.GetItem(item.ID, language, Data.Version.Latest);

            if (latestVersion == null)
            {
                CrawlingLog.Log.Warn(string.Format("ElasticIndexOperations : AddItem : Latest version not found for item {0}. Skipping.", item.Uri));
            }
            else
            {
                var versions = latestVersion.Versions.GetVersions(false);
                if (context.IsParallel)
                {
                    Action <Item> body = delegate(Item version)
                    {
                        try
                        {
                            ApplyPermissionsThenIndex(context, (SitecoreIndexableItem)version, (SitecoreIndexableItem)latestVersion);
                        }
                        catch (Exception exception)
                        {
                            CrawlingLog.Log.Warn(string.Format("ElasticIndexOperations : AddItem : Could not build document data {0}. Skipping.", version.ID.Guid), exception);
                        }
                    };
                    Parallel.ForEach(versions, context.ParallelOptions, body);
                }
                else
                {
                    foreach (var version in versions)
                    {
                        ApplyPermissionsThenIndex(context, (SitecoreIndexableItem)version, (SitecoreIndexableItem)latestVersion);
                    }
                }
            }
        }
        public void Add(IIndexable indexable, IProviderUpdateContext context,
                        ProviderIndexConfiguration indexConfiguration)
        {
            if (indexable == null)
            {
                throw new ArgumentNullException(nameof(indexable));
            }

            CrawlingLog.Log.Debug($"{LogPreffix} {_index.Name} Add {indexable.Id}");

            var doc = BuildDataToIndex(context, indexable);

            if (doc == null)
            {
                Event.RaiseEvent("indexing:excludedfromindex", new object[] { context.Index.Name, indexable.Id });
                return;
            }

            context.AddDocument(doc, (IExecutionContext)null);
        }
        private IndexData BuildDataToIndex(IProviderUpdateContext context, IIndexable version)
        {
            var instance = context.Index.Locator.GetInstance<ICorePipeline>();
            version = CleanUpPipeline.Run(instance, new CleanUpArgs(version, context));
            if (InboundIndexFilterPipeline.Run(instance, new InboundIndexFilterArgs(version)))
            {
                index.Locator.GetInstance<IEvent>().RaiseEvent("indexing:excludedfromindex", new object[2]
                {
                  index.Name,
                  version.UniqueId
                });
                return null;
            }
            var indexData = GetIndexData(version, context);

            if (!indexData.IsEmpty)
                return indexData;
            CrawlingLog.Log.Warn(string.Format("AzureIndexOperations : IndexVersion produced a NULL doc for version {0}. Skipping.", version.UniqueId), null);
            return null;
        }
Ejemplo n.º 34
0
        public virtual void Add(IIndexable indexable, IProviderUpdateContext context, ProviderIndexConfiguration indexConfiguration)
        {
            Assert.ArgumentNotNull(indexable, "indexable");
            Assert.ArgumentNotNull(context, "context");

            bool valid = ItemIsValid(indexable);

            if (!valid)
            {
                return;
            }

            Document document = GetIndexData(indexable, context);
            if (document == null)
            {
                return;
            }

            context.AddDocument(document, indexable.Culture != null ? new CultureExecutionContext(indexable.Culture) : null);
        }
Ejemplo n.º 35
0
        private void UpdateLanguageFallbackDependentItems(IProviderUpdateContext context, SitecoreIndexableItem versionIndexable, IndexEntryOperationContext operationContext)
        {
            if (operationContext == null || operationContext.NeedUpdateAllLanguages)
            {
                return;
            }
            var  item          = versionIndexable.Item;
            bool?currentValue1 = Switcher <bool?, LanguageFallbackFieldSwitcher> .CurrentValue;

            if ((!currentValue1.GetValueOrDefault() ? 1 : (!currentValue1.HasValue ? 1 : 0)) != 0)
            {
                bool?currentValue2 = Switcher <bool?, LanguageFallbackItemSwitcher> .CurrentValue;
                if ((!currentValue2.GetValueOrDefault() ? 1 : (!currentValue2.HasValue ? 1 : 0)) != 0 || StandardValuesManager.IsStandardValuesHolder(item) && item.Fields[FieldIDs.EnableItemFallback].GetValue(false) != "1")
                {
                    return;
                }
                using (new LanguageFallbackItemSwitcher(new bool?(false)))
                {
                    if (item.Fields[FieldIDs.EnableItemFallback].GetValue(true, true, false) != "1")
                    {
                        return;
                    }
                }
            }
            if (!item.Versions.IsLatestVersion())
            {
                return;
            }
            foreach (var indexable in Enumerable.Select(Enumerable.Where <Item>(Enumerable.SelectMany(LanguageFallbackManager.GetDependentLanguages(item.Language, item.Database, item.ID), language =>
            {
                var item2 = item.Database.GetItem(item.ID, language);
                if (item2 == null)
                {
                    return(new Item[0]);
                }
                return(item2.Versions.GetVersions());
            }), item1 => !IsExcludedFromIndex(item1, false)), item1 => PrepareIndexableVersion(item1, context)))
            {
                Operations.Update(indexable, context, context.Index.Configuration);
            }
        }
Ejemplo n.º 36
0
        public void Add(IIndexable indexable, IProviderUpdateContext context, ProviderIndexConfiguration indexConfiguration)
        {
            Assert.ArgumentNotNull(indexable, "indexable");
            Assert.ArgumentNotNull(context, "context");
            var data = BuildDataToIndex(context, indexable);

            if (data == null)
            {
                return;
            }
            if (data.IsEmpty)
            {
                CrawlingLog.Log.Warn(string.Format("AzureIndexOperations.Add(): IndexVersion produced a NULL doc for version {0}. Skipping.", indexable.UniqueId));
            }
            var document = data.BuildDocument();

            ((IAzureProviderIndex)context.Index).AzureSchema.ReconcileAzureIndexSchema(document);

            LogIndexOperation(() => string.Format("Adding indexable UniqueId:{0}, Culture:{1}, DataSource:{2}, Index:{3}", indexable.UniqueId, indexable.Culture, indexable.DataSource, context.Index.Name), data, document);
            context.AddDocument(document, data.Culture != null ? new CultureExecutionContext(data.Culture) : null);
        }
        private JObject BuildDataToIndex(IProviderUpdateContext context, IIndexable version)
        {
            //bool flag = InboundIndexFilterPipeline.Run(context.Index.Locator.GetInstance<ICorePipeline>(), new InboundIndexFilterArgs(version));
            //if (flag)
            //{
            //this.events.RaiseEvent("indexing:excludedfromindex", new object[]
            //{
            //    this.index.Name,
            //    version.UniqueId
            //});
            //return null;
            //}
            var indexData = this.GetIndexData(version, context);

            //if (indexData.IsEmpty)
            //{
            //    CrawlingLog.Log.Warn(string.Format("CrawlerLuceneIndexOperations : IndexVersion produced a NULL doc for version {0}. Skipping.", version.UniqueId), null);
            //    return null;
            //}
            return(indexData);
        }
        protected virtual object BuildIndexableDocument(IIndexable indexable, IProviderUpdateContext context)
        {
            var sitecoreIndexableItem = indexable as SitecoreIndexableItem;

            if (sitecoreIndexableItem != null)
            {
                sitecoreIndexableItem.IndexFieldStorageValueFormatter = context.Index.Configuration.IndexFieldStorageValueFormatter;
            }

            var builderObject = ReflectionUtil.CreateObject(
                context.Index.Configuration.DocumentBuilderType,
                new[] { indexable, context as object });

            var document = this.BuildSolrDocument(builderObject) ?? this.BuildLuceneDocument(builderObject, indexable);

            if (document == null)
            {
                throw new InvalidCastException("Unable to cast builder object.");
            }

            return(document);
        }
Ejemplo n.º 39
0
 public virtual void Update(IIndexable indexable, IProviderUpdateContext context, ProviderIndexConfiguration indexConfiguration)
 {
     Document document = GetIndexData(indexable, context);
     if (document == null)
     {
         CrawlingLog.Log.Warn(
             string.Format(
                 "LuceneIndexOperations.Update(): IndexVersion produced a NULL doc for version {0}. Skipping.",
                 indexable.UniqueId));
         return;
     }
     var updateTerm = new Term("_uniqueid", indexable.UniqueId.Value.ToString());
     context.UpdateDocument(document, updateTerm, indexable.Culture != null ? new CultureExecutionContext(indexable.Culture) : null);
 }
Ejemplo n.º 40
0
        public virtual Document GetIndexData(IIndexable indexable, IProviderUpdateContext context)
        {
            Assert.ArgumentNotNull(indexable, "indexable");
            Assert.ArgumentNotNull(context, "context");
            Assert.Required(index.Configuration.DocumentOptions as LuceneDocumentBuilderOptions, "IDocumentBuilderOptions of wrong type for this crawler");
            SitecoreIndexableItem sitecoreIndexableItem = indexable as SitecoreIndexableItem;
            if (indexable.Id.ToString() == string.Empty || sitecoreIndexableItem == null)
            {
                return null;
            }

            Document document = new Document();

            AddFields(document, sitecoreIndexableItem.Item);

            return document;
        }
 public LuceneCachedDocumentBuilder(IIndexable indexable, IProviderUpdateContext context) : base(indexable, context)
 {
 }
 public void Delete(IIndexable indexable, IProviderUpdateContext context)
 {
     Delete(indexable.Id, context);
 }
 public void Delete(IIndexableId id, IProviderUpdateContext context)
 {
     context.Delete(id);
 }
 public void Delete(IIndexableUniqueId indexableUniqueId, IProviderUpdateContext context)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 45
0
 public virtual void Delete(IIndexableUniqueId indexableUniqueId, IProviderUpdateContext context)
 {
     Assert.ArgumentNotNull(indexableUniqueId, "indexableUniqueId");
     context.Delete(indexableUniqueId);
 }
 public void Delete(IIndexableUniqueId indexableUniqueId, IProviderUpdateContext context)
 {
     Assert.ArgumentNotNull(indexableUniqueId, "indexableUniqueId");
     VerboseLogging.CrawlingLogDebug(() => string.Format("Deleting indexable UniqueId:{0}, Index:{1}", indexableUniqueId, context.Index.Name));
     context.Delete(indexableUniqueId);
 }
 internal IndexData GetIndexData(IIndexable indexable, IProviderUpdateContext context)
 {
     Assert.ArgumentNotNull(indexable, "indexable");
     Assert.ArgumentNotNull(context, "context");
     Assert.Required((index.Configuration.DocumentOptions as AzureDocumentBuilderOptions), "IDocumentBuilderOptions of wrong type for this crawler");
     AzureDocumentBuilder documentBuilder = (AzureDocumentBuilder)ReflectionUtil.CreateObject(context.Index.Configuration.DocumentBuilderType, new object[2]
     {
         indexable,
         context
     });
     if (documentBuilder == null)
     {
         CrawlingLog.Log.Error("Unable to create document builder (" + context.Index.Configuration.DocumentBuilderType + "). Please check your configuration. We will fallback to the default for now.", (Exception)null);
         documentBuilder = new AzureDocumentBuilder(indexable, context);
     }
     documentBuilder.AddSpecialFields();
     documentBuilder.AddItemFields();
     documentBuilder.AddComputedIndexFields();
     documentBuilder.AddBoost();
     var indexData = new IndexData(index, indexable, documentBuilder);
     index.AzureSchema.AddAzureIndexFields(indexData.Fields.Where(f => f.Name != indexData.UpdateTerm.Name).ToList());
     index.AzureSchema.BuildAzureIndexSchema(indexData.UpdateTerm, indexData.FullUpdateTerm);
     return indexData;
 }
Ejemplo n.º 48
0
 public virtual void Delete(IIndexable indexable, IProviderUpdateContext context)
 {
     Assert.ArgumentNotNull(indexable, "indexable");
     Delete(indexable.UniqueId, context);
 }