/// <inheritdoc /> public IndexDocument CompleteIndexDocument(Node node, IndexDocument baseDocument) { if (node == null) { throw new ArgumentNullException(nameof(node)); } var textEtract = new StringBuilder(baseDocument.GetStringValue(IndexFieldName.AllText)); var faultedFieldNames = new List <string>(); if (node is IIndexableDocument ixnode) { foreach (var field in ixnode.GetIndexableFields()) { if (IndexDocument.ForbiddenFields.Contains(field.Name)) { continue; } if (IndexDocument.PostponedFields.Contains(field.Name)) { continue; } if (node.SavingState != ContentSavingState.Finalized && (field.IsBinaryField || SkippedMultistepFields.Contains(field.Name))) { continue; } if (!field.IsBinaryField) { continue; } if (!TextExtractor.TextExtractingWillBePotentiallySlow((BinaryData)((BinaryField)field).GetData())) { continue; } IEnumerable <IndexField> indexFields = null; string extract = null; try { indexFields = field.GetIndexFields(out extract); } catch (Exception) { faultedFieldNames.Add(field.Name); } if (!String.IsNullOrEmpty(extract)) // do not add extra line if extract is empty { try { textEtract.AppendLine(extract); } catch (OutOfMemoryException) { SnLog.WriteWarning("Out of memory error during indexing.", EventId.Indexing, properties: new Dictionary <string, object> { { "Path", node.Path }, { "Field", field.Name } }); } } if (indexFields != null) { foreach (var indexField in indexFields) { baseDocument.Add(indexField); } } } } baseDocument.Add(new IndexField(IndexFieldName.AllText, textEtract.ToString(), IndexingMode.Analyzed, IndexStoringMode.No, IndexTermVector.Default)); if (faultedFieldNames.Any()) { if (!baseDocument.GetBooleanValue(IndexFieldName.IsFaulted)) { baseDocument.Add(new IndexField(IndexFieldName.IsFaulted, true, IndexingMode.NotAnalyzed, IndexStoringMode.Yes, IndexTermVector.Default)); } foreach (var faultedFieldName in faultedFieldNames) { baseDocument.Add(new IndexField(IndexFieldName.FaultedFieldName, faultedFieldName, IndexingMode.NotAnalyzed, IndexStoringMode.Yes, IndexTermVector.Default)); } } return(baseDocument); }