Beispiel #1
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);
                }
            }
        }
        public void AddIndex(ISearchIndex index)
        {
            Assert.ArgumentNotNull(index, "index");
            Assert.IsFalse((this.Indexes.ContainsKey(index.Name) ? 1 : 0) != 0, "An index with the name \"{0}\" have already been added.", index.Name);
            this.Indexes[index.Name] = index;
            if (index.Configuration == null)
            {
                XmlNode configNode = this.factory.GetConfigNode(this.DefaultIndexConfigurationPath);
                if (configNode == null)
                {
                    throw new ConfigurationException("Index must have a ProviderIndexConfiguration associated with it. Please check your config.");
                }
                ProviderIndexConfiguration @object = this.factory.CreateObject <ProviderIndexConfiguration>(configNode);
                if (@object == null)
                {
                    throw new ConfigurationException("Unable to create configuration object from path specified in setting 'ContentSearch.DefaultIndexConfigurationPath'. Please check your config.");
                }
                index.Configuration = @object;
            }
            if (!index.Configuration.InitializeOnAdd)
            {
                return;
            }

            index.Initialize();
        }
        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 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);
        }
        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);
        }
        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);
        }
Beispiel #8
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);
        }
Beispiel #9
0
        public override object ComputeFieldValue(IIndexable indexable)
        {
            Item item = indexable as SitecoreIndexableItem;

            if (item == null)
            {
                return(null);
            }

            if (item.IsCatalogItem())
            {
                //add product content
                ProviderIndexConfiguration config = ContentSearchManager.GetIndex(indexable).Configuration;
                return(ExtractTextFields(item, config));
            }

            return(base.ComputeFieldValue(indexable));
        }
        public LinqToAlgoliaIndex(AlgoliaSearchContext context,
                                  IExecutionContext executionContext)
        {
            Assert.ArgumentNotNull(context, "context");
            _context = context;

            var index = context.Index as AlgoliaBaseIndex;

            if (index == null)
            {
                throw new ArgumentException("context.Index should be instance of AlgoliaBaseIndex");
            }

            _repository          = index.Repository;
            _configuration       = context.Index.Configuration;
            _queryOptimizer      = new AlgoliaQueryOptimizer();
            _mapper              = new AlgoliaQueryMapper();
            _fieldNameTranslator = context.Index.FieldNameTranslator;
        }
        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);
        }
Beispiel #12
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);
        }
Beispiel #13
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);
        }
Beispiel #14
0
 public void Update(IIndexable indexable, IProviderUpdateContext context, ProviderIndexConfiguration indexConfiguration)
 {
     throw new NotImplementedException();
 }
Beispiel #15
0
 public void Update(IIndexable indexable, IProviderUpdateContext context, ProviderIndexConfiguration indexConfiguration)
 {
     Assert.ArgumentNotNull(indexable, "indexable");
     Add(indexable, context, indexConfiguration);
 }
Beispiel #16
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);
 }