Exemplo n.º 1
0
        /// <summary>
        /// index all supplied nodes (and their detached content)
        /// </summary>
        /// <param name="nodes">collection of nodes (and any detached content they may have) to be indexed</param>
        internal void Index(IPublishedContent[] nodes)
        {
            var indexWriter = this.GetIndexWriter();

            foreach (var node in nodes)
            {
                var indexingContext = new IndexingContext(null, node, this.Name);

                var document = new Document();

                LookService.Index(indexingContext, document);

                indexWriter.AddDocument(document);

                foreach (var detachedContent in node.GetFlatDetachedDescendants())
                {
                    indexingContext = new IndexingContext(node, detachedContent, this.Name);

                    document = new Document();

                    LookService.Index(indexingContext, document);

                    indexWriter.AddDocument(document); // index each detached item
                }

                indexWriter.Commit();

                //indexWriter.Optimize();
            }
        }
Exemplo n.º 2
0
        //protected override void AddDocument(Dictionary<string, string> fields, IndexWriter writer, int nodeId, string type)
        //{
        //    base.AddDocument(fields, writer, nodeId, type);
        //}

        //protected override void AddSingleNodeToIndex(XElement node, string type)
        //{
        //    base.AddSingleNodeToIndex(node, type);
        //}

        //protected override IndexWriter CreateIndexWriter()
        //{
        //    var debug = base.CreateIndexWriter();
        //    return debug;
        //}

        //public override void DeleteFromIndex(string nodeId)
        //{
        //    base.DeleteFromIndex(nodeId);
        //}

        //protected override Dictionary<string, string> GetDataToIndex(XElement node, string type)
        //{
        //    var debug = base.GetDataToIndex(node, type);
        //    return debug;
        //}

        //protected override IIndexCriteria GetIndexerData(IndexSet indexSet)
        //{
        //    var debug = base.GetIndexerData(indexSet);
        //    return debug;
        //}

        //public override Directory GetLuceneDirectory()
        //{
        //    var debug = base.GetLuceneDirectory();
        //    return debug;
        //}

        //protected override FieldIndexTypes GetPolicy(string fieldName)
        //{
        //    var debug = base.GetPolicy(fieldName);
        //    return debug;
        //}

        //protected override Dictionary<string, string> GetSpecialFieldsToIndex(Dictionary<string, string> allValuesForIndexing)
        //{
        //    var debug = base.GetSpecialFieldsToIndex(allValuesForIndexing);
        //    return debug;
        //}

        //public override void IndexAll(string type)
        //{
        //    base.IndexAll(type);
        //}

        //public override bool IndexExists()
        //{
        //    var debug = base.IndexExists();
        //    return debug;
        //}

        //protected override void OnDocumentWriting(DocumentWritingEventArgs docArgs)
        //{
        //    base.OnDocumentWriting(docArgs);
        //}

        //protected override void OnDuplicateFieldWarning(int nodeId, string indexSetName, string fieldName)
        //{
        //    base.OnDuplicateFieldWarning(nodeId, indexSetName, fieldName);
        //}

        //protected override void OnGatheringFieldData(IndexingFieldDataEventArgs e)
        //{
        //    base.OnGatheringFieldData(e);
        //}

        //protected override void OnGatheringNodeData(IndexingNodeDataEventArgs e)
        //{
        //    base.OnGatheringNodeData(e);
        //}

        //protected override void OnIgnoringNode(IndexingNodeDataEventArgs e)
        //{
        //    base.OnIgnoringNode(e);
        //}

        //protected override void OnIndexDeleted(DeleteIndexEventArgs e)
        //{
        //    base.OnIndexDeleted(e);
        //}

        //protected override void OnIndexingError(IndexingErrorEventArgs e)
        //{
        //    base.OnIndexingError(e);
        //}

        //protected override void OnIndexOperationComplete(EventArgs e)
        //{
        //    base.OnIndexOperationComplete(e);
        //}

        //protected override void OnIndexOptimized(EventArgs e)
        //{
        //    base.OnIndexOptimized(e);
        //}

        //protected override void OnIndexOptimizing(EventArgs e)
        //{
        //    base.OnIndexOptimizing(e);
        //}

        //protected override void OnNodeIndexed(IndexedNodeEventArgs e)
        //{
        //    base.OnNodeIndexed(e);
        //}

        //protected override void OnNodeIndexing(IndexingNodeEventArgs e)
        //{
        //    base.OnNodeIndexing(e);
        //}

        //protected override void OnNodesIndexed(IndexedNodesEventArgs e)
        //{
        //    base.OnNodesIndexed(e);
        //}

        //protected override void OnNodesIndexing(IndexingNodesEventArgs e)
        //{
        //    base.OnNodesIndexing(e);
        //}

        //public override void ReIndexNode(XElement node, string type)
        //{
        //    base.ReIndexNode(node, type);
        //}

        //protected override bool ValidateDocument(XElement node)
        //{
        //    return base.ValidateDocument(node);
        //}

        /// <summary>
        /// index all supplied nodes (and their detached content)
        /// </summary>
        /// <param name="nodes">collection of nodes (and any detached content they may have) to be indexed</param>
        internal void Index(IPublishedContent[] nodes)
        {
#if DEBUG
            var stopwatch = Stopwatch.StartNew();
#endif
            var indexWriter = this.GetIndexWriter();

            foreach (var node in nodes)
            {
                var indexingContext = new IndexingContext(
                    hostNode: null,
                    node: node,
                    indexerName: this.Name);

                var document = new Document();

                LookService.Index(indexingContext, document);

                indexWriter.AddDocument(document);

                foreach (var detachedNode in node.GetDetachedDescendants())
                {
                    indexingContext = new IndexingContext(
                        hostNode: node,
                        node: detachedNode,
                        indexerName: this.Name);

                    document = new Document();

                    LookService.Index(indexingContext, document);

                    indexWriter.AddDocument(document); // index each detached item
                }
            }

            indexWriter.Commit();
#if DEBUG
            stopwatch.Stop();
            LogHelper.Debug(typeof(LookService), $"Indexing { nodes.Length } Item(s) Took { stopwatch.ElapsedMilliseconds }ms");
#endif
        }
Exemplo n.º 3
0
        /// <summary>
        /// index all supplied nodes (and their detached content)
        /// </summary>
        /// <param name="nodes">collection of nodes conent/media/member nodes to be indexed</param>
        /// <param name="indexItem">when true, indicates the IPublishedContent nodes should be indexed</param>
        /// <param name="indexDetached">when true, indicates the detached items for each node should be indexed</param>
        internal void Index(IEnumerable <IPublishedContent> nodes, bool indexItem, bool indexDetached)
        {
            if (!nodes.Any())
            {
                return;
            }

            if (!indexItem && !indexDetached)
            {
                return;                               // possible
            }
            var stopwatch = Stopwatch.StartNew();
            var counter   = 0;

            var indexWriter = this.GetIndexWriter();

            foreach (var node in nodes)
            {
                IndexingContext indexingContext;
                Document        document;

                if (indexItem)
                {
                    indexingContext = new IndexingContext(null, node, this.Name);

                    document = new Document();

                    LookService.Index(indexingContext, document);

                    if (!indexingContext.Cancelled)
                    {
                        counter++;

                        indexWriter.AddDocument(document);
                    }
                }

                if (indexDetached)
                {
                    IPublishedContent[] detachedNodes = null;

                    try
                    {
                        // SEOChecker prior to 2.2 doesn't handle IPublishedContent without an ID
                        detachedNodes = node.GetDetachedDescendants();
                    }
                    catch (Exception exception)
                    {
                        LogHelper.WarnWithException(typeof(LookIndexer), "Error handling Detached items", exception);
                    }
                    finally
                    {
                        if (detachedNodes != null)
                        {
                            foreach (var detachedNode in detachedNodes)
                            {
                                indexingContext = new IndexingContext(node, detachedNode, this.Name);

                                document = new Document();

                                LookService.Index(indexingContext, document);

                                if (!indexingContext.Cancelled)
                                {
                                    counter++;

                                    indexWriter.AddDocument(document); // index each detached item
                                }
                            }
                        }
                    }
                }
            }

            indexWriter.Commit();

            stopwatch.Stop();

            if (counter > 0)
            {
                LogHelper.Debug(typeof(LookIndexer), $"Indexing { counter } Item(s) Took { stopwatch.ElapsedMilliseconds }ms");
            }
        }