public STT.Task FinalizeTextExtractingAsync(object data, IndexDocumentData indexDocument, CancellationToken cancellationToken) { var state = (DocumentPopulatorData)data; var versioningInfo = GetVersioningInfo(state); return(UpdateVersionAsync(state, versioningInfo, indexDocument, cancellationToken)); }
public void CommitPopulateNode(object data, IndexDocumentData indexDocument = null) { var state = (DocumentPopulatorData)data; var versioningInfo = GetVersioningInfo(state); var settings = state.Settings; using (var op = SnTrace.Index.StartOperation("DocumentPopulator.CommitPopulateNode. Version: {0}, VersionId: {1}, Path: {2}", state.Node.Version, state.Node.VersionId, state.Node.Path)) { if (!state.OriginalPath.Equals(state.NewPath, StringComparison.InvariantCultureIgnoreCase)) { DeleteTree(state.OriginalPath, state.Node.Id, true); PopulateTree(state.NewPath, state.Node.Id); } else if (state.IsNewNode) { CreateBrandNewNode(state.Node, versioningInfo, indexDocument); } else if (state.Settings.IsNewVersion()) { AddNewVersion(state.Node, versioningInfo, indexDocument); } else { UpdateVersion(state, versioningInfo, indexDocument); } OnNodeIndexed(state.Node.Path); op.Successful = true; } }
public async STT.Task CommitPopulateNodeAsync(object data, IndexDocumentData indexDocument, CancellationToken cancellationToken) { var state = (DocumentPopulatorData)data; var versioningInfo = GetVersioningInfo(state); using (var op = SnTrace.Index.StartOperation("DocumentPopulator.CommitPopulateNode. Version: {0}, VersionId: {1}, Path: {2}", state.Node.Version, state.Node.VersionId, state.Node.Path)) { if (!state.OriginalPath.Equals(state.NewPath, StringComparison.InvariantCultureIgnoreCase)) { await DeleteTreeAsync(state.OriginalPath, state.Node.Id, cancellationToken).ConfigureAwait(false); await AddTreeAsync(state.NewPath, state.Node.Id, cancellationToken).ConfigureAwait(false); } else if (state.IsNewNode) { await CreateBrandNewNodeAsync(state.Node, versioningInfo, indexDocument, cancellationToken).ConfigureAwait(false); } else if (state.Settings.IsNewVersion()) { await AddNewVersionAsync(state.Node, versioningInfo, indexDocument, cancellationToken).ConfigureAwait(false); } else { await UpdateVersionAsync(state, versioningInfo, indexDocument, cancellationToken).ConfigureAwait(false); } var node = state.Node; OnNodeIndexed(node.Path, node.Id, node.VersionId, node.Version.ToString()); op.Successful = true; } }
internal static void SaveNodeData(Node node, NodeSaveSettings settings, out IndexDocumentData indexDocument) { indexDocument = null; var isNewNode = node.Id == 0; var data = node.Data; var deadlockCount = 0; var isDeadlock = false; while (deadlockCount++ < maxDeadlockIterations) { isDeadlock = !SaveNodeDataTransactional(node, settings, out indexDocument); if (!isDeadlock) { break; } Logger.WriteWarning("Deadlock detected in SaveNodeData", new Dictionary <string, object> { { "Id: ", node.Id }, { "Path: ", node.Path }, { "Version: ", node.Version } }); System.Threading.Thread.Sleep(sleepIfDeadlock); } if (isNewNode) { Logger.WriteVerbose("Node created.", CollectLoggerProperties, data); } else { Logger.WriteVerbose("Node updated.", CollectLoggerProperties, data); } }
public void FinalizeTextExtracting(object data, IndexDocumentData indexDocument) { var state = (DocumentPopulatorData)data; var versioningInfo = GetVersioningInfo(state); UpdateVersion(state, versioningInfo, indexDocument); }
public static IndexDocumentData SaveIndexDocument(Node node, IndexDocumentData indexDocumentData) { if (node.Id == 0) { throw new NotSupportedException("Cannot save the indexing information before node is not saved."); } node.MakePrivateData(); // this is important because version timestamp will be changed. var completedDocument = IndexDocumentProvider.CompleteIndexDocument(node, indexDocumentData.IndexDocument); byte[] bytes; if (completedDocument != null) { using (var docStream = new MemoryStream()) { var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); formatter.Serialize(docStream, completedDocument); docStream.Flush(); docStream.Position = 0; bytes = docStream.GetBuffer(); DataProvider.SaveIndexDocument(node.Data, bytes); } } else { bytes = new byte[0]; } return(CreateIndexDocumentData(node, completedDocument, bytes)); }
public void FinalizeTextExtracting(object data, IndexDocumentData indexDocument) { var state = (DocumentPopulatorData)data; UpdateVersion(state, indexDocument); //OnNodeIndexed(state.Node.Path); }
public void CommitPopulateNode(object data, IndexDocumentData indexDocument = null) { var state = (DocumentPopulatorData)data; #if INDEX DetailedLogger.Log("Populating node. V:{0}, VId:{1}, Path:{2}", state.Node.Version, state.Node.VersionId, state.Node.Path); // category: INDEX #endif if (!state.OriginalPath.Equals(state.NewPath, StringComparison.InvariantCultureIgnoreCase)) { DeleteTree(state.OriginalPath, true); PopulateTree(state.NewPath); } else if (state.IsNewNode) { CreateBrandNewNode(state.Node, indexDocument); } else if (state.Settings.IsNewVersion()) { AddNewVersion(state.Node, indexDocument); } else { UpdateVersion(state, indexDocument); } OnNodeIndexed(state.Node.Path); }
// caller: CommitPopulateNode private static void UpdateVersion(DocumentPopulatorData state, IndexDocumentData indexDocumentData) { foreach (var versionId in state.Settings.DeletableVersionIds) { ExecuteActivity(CreateActivity(IndexingActivityType.RemoveDocument, state.Node.Id, versionId, 0, null, null)); } if (!state.Settings.DeletableVersionIds.Contains(state.Node.VersionId)) { ExecuteActivity(CreateActivity(IndexingActivityType.UpdateDocument, state.Node.Id, state.Node.VersionId, state.Node.VersionTimestamp, null, indexDocumentData)); } }
internal static Document GetDocument(IndexDocumentData docData) { var buffer = docData.IndexDocumentInfoBytes; //if (buffer.Length == 0) // return null; var docStream = new System.IO.MemoryStream(buffer); var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); var info = (IndexDocumentInfo)formatter.Deserialize(docStream); return(CreateDocument(info, docData)); }
public static Document CreateDocument(Node node) //caller: tests { var info = Create(node); var data = new IndexDocumentData { Path = node.Path, ParentId = node.ParentId, IsLastPublic = node.IsLastPublicVersion, IsLastDraft = node.IsLatestVersion }; return(CreateDocument(info, data)); }
public static Document CreateDocument(Node node, bool isNew) // caller: tests { var info = Create(node, false, isNew); var data = new IndexDocumentData(null, null) { Path = node.Path, ParentId = node.ParentId, IsSystem = node.IsSystem, IsLastPublic = node.IsLastPublicVersion, IsLastDraft = node.IsLatestVersion }; return(CreateDocument(info, data)); }
private IEnumerable <Fieldable> GetFieldsPrivate(IndexDocumentInfo info, IndexDocumentData docData) { var fields = new List <Fieldable>(); foreach (var provider in _providers) { var f = provider.GetFields(docData); if (f != null) { fields.AddRange(f); } } return(fields.Count == 0 ? null : fields); }
public IndexDocument CompleteIndexDocument(IndexDocumentData docData) { var doc = docData?.IndexDocument; if (doc == null) { return(null); } if (doc is NotIndexedIndexDocument) { return(null); } var path = docData.Path.ToLowerInvariant(); var parentPath = RepositoryPath.GetParentPath(docData.Path)?.ToLowerInvariant() ?? "/"; doc.Add(new IndexField(IndexFieldName.Name, RepositoryPath.GetFileName(path), NameFieldIndexingInfo.IndexingMode, NameFieldIndexingInfo.IndexStoringMode, NameFieldIndexingInfo.TermVectorStoringMode)); doc.Add(new IndexField(IndexFieldName.Path, path, PathFieldIndexingInfo.IndexingMode, PathFieldIndexingInfo.IndexStoringMode, PathFieldIndexingInfo.TermVectorStoringMode)); doc.Add(new IndexField(IndexFieldName.Depth, Node.GetDepth(path), IndexingMode.AnalyzedNoNorms, IndexStoringMode.Yes, IndexTermVector.No)); doc.Add(new IndexField(IndexFieldName.InTree, GetParentPaths(path), InTreeFieldIndexingInfo.IndexingMode, InTreeFieldIndexingInfo.IndexStoringMode, InTreeFieldIndexingInfo.TermVectorStoringMode)); doc.Add(new IndexField(IndexFieldName.InFolder, parentPath, InFolderFieldIndexingInfo.IndexingMode, InFolderFieldIndexingInfo.IndexStoringMode, InFolderFieldIndexingInfo.TermVectorStoringMode)); doc.Add(new IndexField(IndexFieldName.ParentId, docData.ParentId, IndexingMode.AnalyzedNoNorms, IndexStoringMode.No, IndexTermVector.No)); doc.Add(new IndexField(IndexFieldName.IsSystem, docData.IsSystem, IndexingMode.NotAnalyzed, IndexStoringMode.Yes, IndexTermVector.No)); // flags doc.Add(new IndexField(IndexFieldName.IsLastPublic, docData.IsLastPublic, IndexingMode.NotAnalyzed, IndexStoringMode.Yes, IndexTermVector.No)); doc.Add(new IndexField(IndexFieldName.IsLastDraft, docData.IsLastDraft, IndexingMode.NotAnalyzed, IndexStoringMode.Yes, IndexTermVector.No)); // timestamps doc.Add(new IndexField(IndexFieldName.NodeTimestamp, docData.NodeTimestamp, IndexingMode.AnalyzedNoNorms, IndexStoringMode.Yes, IndexTermVector.No)); doc.Add(new IndexField(IndexFieldName.VersionTimestamp, docData.VersionTimestamp, IndexingMode.AnalyzedNoNorms, IndexStoringMode.Yes, IndexTermVector.No)); return(doc); }
public void CommitPopulateNode(object data, IndexDocumentData indexDocument = null) { var state = (DocumentPopulatorData)data; if (state.OriginalPath.ToLower() != state.NewPath.ToLower()) { DeleteTree(state.OriginalPath, true); PopulateTree(state.NewPath); } else if (state.IsNewNode) { CreateBrandNewNode(state.Node, indexDocument); } else if (state.Settings.IsNewVersion()) { AddNewVersion(state.Node, indexDocument); } else { UpdateVersion(state, indexDocument); } OnNodeIndexed(state.Node.Path); }
public override void Distribute() { // check doc size before distributing var sendDocOverMSMQ = _indexDocumentData != null && _indexDocumentData.IndexDocumentInfoSize.HasValue && _indexDocumentData.IndexDocumentInfoSize.Value < RepositoryConfiguration.MsmqIndexDocumentSizeLimit; if (sendDocOverMSMQ) { // document is small to send over MSMQ //Trace.WriteLine("###I> DOCUMENT IS SMALL"); base.Distribute(); } else { // document is too large, send activity without the document //Trace.WriteLine("###I> DOCUMENT IS LARGE"); var docData = _indexDocumentData; _indexDocumentData = null; base.Distribute(); // restore indexdocument after activity is sent _indexDocumentData = docData; } }
/*================================================================================================================================*/ // caller: CommitPopulateNode private static void CreateBrandNewNode(Node node, VersioningInfo versioningInfo, IndexDocumentData indexDocumentData) { CreateActivityAndExecute(IndexingActivityType.AddDocument, node.Path, node.Id, node.VersionId, node.VersionTimestamp, true, versioningInfo, indexDocumentData); }
internal static Document CreateDocument(IndexDocumentInfo info, IndexDocumentData docData) { if (info is NotIndexedIndexDocumentInfo) { return(null); } var doc = new Document(); foreach (var fieldInfo in info.fields) { if (fieldInfo.Name != "Password" && fieldInfo.Name != "PasswordHash") { doc.Add(CreateField(fieldInfo)); } } var path = docData.Path.ToLowerInvariant(); doc.Add(CreateStringField(LucObject.FieldName.Name, RepositoryPath.GetFileName(path), NameFieldIndexingInfo)); doc.Add(CreateStringField(LucObject.FieldName.Path, path, PathFieldIndexingInfo)); //LucObject.FieldName.Depth var nf = new NumericField(LucObject.FieldName.Depth, Field.Store.YES, true); nf.SetIntValue(DepthIndexHandler.GetDepth(docData.Path)); doc.Add(nf); //LucObject.FieldName.InTree //var fields = InTreeIndexHandlerInstance.GetIndexFields(LucObject.FieldName.InTree, docData.Path); var fields = CreateInTreeFields(LucObject.FieldName.InTree, docData.Path); foreach (var field in fields) { doc.Add(field); } //LucObject.FieldName.InFolder doc.Add(CreateInFolderField(LucObject.FieldName.InFolder, path)); //LucObject.FieldName.ParentId nf = new NumericField(LucObject.FieldName.ParentId, Field.Store.NO, true); nf.SetIntValue(docData.ParentId); doc.Add(nf); //LucObject.FieldName.IsSystem //doc.RemoveFields(LucObject.FieldName.IsSystem); doc.Add(new Field(LucObject.FieldName.IsSystem, docData.IsSystem ? BooleanIndexHandler.YES : BooleanIndexHandler.NO, Field.Store.YES, Field.Index.NOT_ANALYZED, Field.TermVector.NO)); // flags doc.Add(new Field(LucObject.FieldName.IsLastPublic, docData.IsLastPublic ? BooleanIndexHandler.YES : BooleanIndexHandler.NO, Field.Store.YES, Field.Index.NOT_ANALYZED, Field.TermVector.NO)); doc.Add(new Field(LucObject.FieldName.IsLastDraft, docData.IsLastDraft ? BooleanIndexHandler.YES : BooleanIndexHandler.NO, Field.Store.YES, Field.Index.NOT_ANALYZED, Field.TermVector.NO)); // timestamps nf = new NumericField(LucObject.FieldName.NodeTimestamp, Field.Store.YES, true); nf.SetLongValue(docData.NodeTimestamp); doc.Add(nf); nf = new NumericField(LucObject.FieldName.VersionTimestamp, Field.Store.YES, true); nf.SetLongValue(docData.VersionTimestamp); doc.Add(nf); // custom fields if (info.HasCustomField) { var customFields = CustomIndexFieldManager.GetFields(info, docData); if (customFields != null) { foreach (var field in customFields) { doc.Add(field); } } } return(doc); }
private static void CreateActivityAndExecute(IndexingActivityType type, int nodeId, int versionId, long versionTimestamp, bool? singleVersion, IndexDocumentData indexDocumentData) { ExecuteActivity(CreateActivity(type, nodeId, versionId, versionTimestamp, singleVersion, indexDocumentData)); }
/*================================================================================================================================*/ private static IndexingActivity CreateActivity(IndexingActivityType type, int nodeId, int versionId, long versionTimestamp, bool? singleVersion, IndexDocumentData indexDocumentData) { return new IndexingActivity { ActivityType = type, NodeId = nodeId, VersionId = versionId, VersionTimestamp = versionTimestamp, SingleVersion = singleVersion, IndexDocumentData = indexDocumentData }; }
// caller: CommitPopulateNode private static void AddNewVersion(Node newVersion, IndexDocumentData indexDocumentData) { CreateActivityAndExecute(IndexingActivityType.AddDocument, newVersion.Id, newVersion.VersionId, newVersion.VersionTimestamp, null, indexDocumentData); //UNDONE: SingleVersion }
public STT.Task CommitPopulateNodeAsync(object data, IndexDocumentData indexDocument, CancellationToken cancellationToken) { return(STT.Task.CompletedTask); }
public void CommitPopulateNode(object data, IndexDocumentData indexDocument) { }
private static LuceneIndexingActivity CreateTreeActivity(IndexingActivityType type, string path, int nodeId, bool moveOrRename, IndexDocumentData indexDocumentData) { var activity = (LuceneIndexingActivity)IndexingActivityFactory.Instance.CreateActivity(type); activity.Path = path.ToLowerInvariant(); activity.NodeId = nodeId; activity.MoveOrRename = moveOrRename; if (indexDocumentData != null) { var lucDocAct = activity as LuceneDocumentActivity; if (lucDocAct != null) { lucDocAct.IndexDocumentData = indexDocumentData; } } return(activity); }
/*================================================================================================================================*/ private static LuceneIndexingActivity CreateActivity(IndexingActivityType type, string path, int nodeId, int versionId, long versionTimestamp, bool?singleVersion, VersioningInfo versioningInfo, IndexDocumentData indexDocumentData) { var activity = (LuceneIndexingActivity)IndexingActivityFactory.Instance.CreateActivity(type); activity.Path = path.ToLowerInvariant(); activity.NodeId = nodeId; activity.VersionId = versionId; activity.VersionTimestamp = versionTimestamp; activity.SingleVersion = singleVersion; if (indexDocumentData != null) { var lucDocAct = activity as LuceneDocumentActivity; if (lucDocAct != null) { lucDocAct.IndexDocumentData = indexDocumentData; } } var documentActivity = activity as LuceneDocumentActivity; if (documentActivity != null) { documentActivity.Versioning = versioningInfo; } return(activity); }
// caller: CommitPopulateNode private static void UpdateVersion(DocumentPopulatorData state, VersioningInfo versioningInfo, IndexDocumentData indexDocumentData) { CreateActivityAndExecute(IndexingActivityType.UpdateDocument, state.OriginalPath, state.Node.Id, state.Node.VersionId, state.Node.VersionTimestamp, null, versioningInfo, indexDocumentData); }
// caller: CommitPopulateNode private static void AddNewVersion(Node newVersion, VersioningInfo versioningInfo, IndexDocumentData indexDocumentData) { CreateActivityAndExecute(IndexingActivityType.AddDocument, newVersion.Path, newVersion.Id, newVersion.VersionId, newVersion.VersionTimestamp, null, versioningInfo, indexDocumentData); }
internal static void SaveNodeData(Node node, NodeSaveSettings settings, out IndexDocumentData indexDocument) { indexDocument = null; var isNewNode = node.Id == 0; var data = node.Data; var deadlockCount = 0; var isDeadlock = false; while (deadlockCount++ < maxDeadlockIterations) { isDeadlock = !SaveNodeDataTransactional(node, settings, out indexDocument); if (!isDeadlock) break; Logger.WriteWarning("Deadlock detected in SaveNodeData", new Dictionary<string, object> { { "Id: ", node.Id }, { "Path: ", node.Path }, { "Version: ", node.Version } }); System.Threading.Thread.Sleep(sleepIfDeadlock); } if (isNewNode) Logger.WriteVerbose("Node created.", CollectLoggerProperties, data); else Logger.WriteVerbose("Node updated.", CollectLoggerProperties, data); }
private static bool SaveNodeDataTransactional(Node node, NodeSaveSettings settings, out IndexDocumentData indexDocument) { indexDocument = null; var data = node.Data; var isNewNode = data.Id == 0; var isLocalTransaction = !TransactionScope.IsActive; if (isLocalTransaction) TransactionScope.Begin(); try { data.CreateSnapshotData(); var participant = new NodeDataParticipant { Data = data, Settings = settings, IsNewNode = isNewNode }; TransactionScope.Participate(participant); int lastMajorVersionId, lastMinorVersionId; DataProvider.Current.SaveNodeData(data, settings, out lastMajorVersionId, out lastMinorVersionId); //-- here we re-create the node head to insert it into the cache and refresh the version info if (lastMajorVersionId > 0 || lastMinorVersionId > 0) { var head = NodeHead.CreateFromNode(node, lastMinorVersionId, lastMajorVersionId); if (MustCache(node.NodeType)) { //-- participate cache items var idKey = CreateNodeHeadIdCacheKey(head.Id); var participant2 = new InsertCacheParticipant { CacheKey = idKey }; TransactionScope.Participate(participant2); var pathKey = CreateNodeHeadPathCacheKey(head.Path); var participant3 = new InsertCacheParticipant { CacheKey = pathKey }; TransactionScope.Participate(participant3); CacheNodeHead(head, idKey, pathKey); } node.RefreshVersionInfo(head); if (!settings.DeletableVersionIds.Contains(node.VersionId)) indexDocument = SaveIndexDocument(node); } if (isLocalTransaction) TransactionScope.Commit(); } catch (System.Data.Common.DbException dbe) { if (isLocalTransaction && IsDeadlockException(dbe)) return false; throw SavingExceptionHelper(data, dbe); } catch (Exception e) { var ee = SavingExceptionHelper(data, e); if (ee == e) throw; else throw ee; } finally { if (isLocalTransaction && TransactionScope.IsActive) TransactionScope.Rollback(); } return true; }
public static Document CreateDocument(Node node) //caller: tests { var info = Create(node); var data = new IndexDocumentData { Path = node.Path, ParentId = node.ParentId, IsLastPublic = node.IsLastPublicVersion, IsLastDraft = node.IsLatestVersion }; return CreateDocument(info, data); }
/*================================================================================================================================*/ // caller: CommitPopulateNode private static void CreateBrandNewNode(Node node, IndexDocumentData indexDocumentData) { CreateActivityAndExecute(IndexingActivityType.AddDocument, node.Id, node.VersionId, node.VersionTimestamp, true, indexDocumentData); }
internal static Document GetDocument(IndexDocumentData docData) { var buffer = docData.IndexDocumentInfoBytes; //if (buffer.Length == 0) // return null; var docStream = new System.IO.MemoryStream(buffer); var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); var info = (IndexDocumentInfo)formatter.Deserialize(docStream); return CreateDocument(info, docData); }
// caller: CommitPopulateNode private static void UpdateVersion(DocumentPopulatorData state, IndexDocumentData indexDocumentData) { foreach (var versionId in state.Settings.DeletableVersionIds) ExecuteActivity(CreateActivity(IndexingActivityType.RemoveDocument, state.Node.Id, versionId, 0, null, null));//UNDONE: SingleVersion if (!state.Settings.DeletableVersionIds.Contains(state.Node.VersionId)) ExecuteActivity(CreateActivity(IndexingActivityType.UpdateDocument, state.Node.Id, state.Node.VersionId, state.Node.VersionTimestamp, null, indexDocumentData));//UNDONE: SingleVersion }
private IndexDocument CreateIndexDocument(IndexDocumentData data) { return(data == null ? null : CompleteIndexDocument(data)); }
private static IndexingActivity CreateActivity(IndexingActivityType type, string path, bool moveOrRename, IndexDocumentData indexDocumentData) { return new IndexingActivity { ActivityType = type, Path = path.ToLower(), IndexDocumentData = indexDocumentData, MoveOrRename = moveOrRename }; }
private IEnumerable<Fieldable> GetFieldsPrivate(IndexDocumentInfo info, IndexDocumentData docData) { var fields = new List<Fieldable>(); foreach (var provider in _providers) { var f = provider.GetFields(docData); if (f != null) fields.AddRange(f); } return fields.Count == 0 ? null : fields; }
private static void CreateActivityAndExecute(IndexingActivityType type, string path, bool moveOrRename, IndexDocumentData indexDocumentData) { ExecuteActivity(CreateActivity(type, path, moveOrRename, indexDocumentData)); }
private static void CreateActivityAndExecute(IndexingActivityType type, string path, int nodeId, int versionId, long versionTimestamp, bool?singleVersion, VersioningInfo versioningInfo, IndexDocumentData indexDocumentData) { ExecuteActivity(CreateActivity(type, path, nodeId, versionId, versionTimestamp, singleVersion, versioningInfo, indexDocumentData)); }
internal static Document CreateDocument(IndexDocumentInfo info, IndexDocumentData docData) { var doc = new Document(); foreach (var fieldInfo in info.fields) doc.Add(CreateField(fieldInfo)); var path = docData.Path.ToLower(); //doc.Add(new Field(LucObject.FieldName.Name, RepositoryPath.GetFileName(path), Field.Store.YES, Field.Index.ANALYZED)); //doc.Add(new Field(LucObject.FieldName.Path, path, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS)); doc.Add(CreateStringField(LucObject.FieldName.Name, RepositoryPath.GetFileName(path), NameFieldIndexingInfo)); doc.Add(CreateStringField(LucObject.FieldName.Path, path, NameFieldIndexingInfo)); //LucObject.FieldName.Depth var nf = new NumericField(LucObject.FieldName.Depth, Field.Store.YES, true); nf.SetIntValue(DepthIndexHandler.GetDepth(docData.Path)); doc.Add(nf); //LucObject.FieldName.InTree //var fields = InTreeIndexHandlerInstance.GetIndexFields(LucObject.FieldName.InTree, docData.Path); var fields = CreateInTreeFields(LucObject.FieldName.InTree, docData.Path); foreach (var field in fields) doc.Add(field); //LucObject.FieldName.InFolder doc.Add(CreateInFolderField(LucObject.FieldName.InFolder, path)); //LucObject.FieldName.ParentId nf = new NumericField(LucObject.FieldName.ParentId, Field.Store.NO, true); nf.SetIntValue(docData.ParentId); doc.Add(nf); // flags doc.Add(new Field(LucObject.FieldName.IsLastPublic, docData.IsLastPublic ? BooleanIndexHandler.YES : BooleanIndexHandler.NO, Field.Store.YES, Field.Index.NOT_ANALYZED, Field.TermVector.NO)); doc.Add(new Field(LucObject.FieldName.IsLastDraft, docData.IsLastDraft ? BooleanIndexHandler.YES : BooleanIndexHandler.NO, Field.Store.YES, Field.Index.NOT_ANALYZED, Field.TermVector.NO)); // timestamps nf = new NumericField(LucObject.FieldName.NodeTimestamp, Field.Store.YES, true); nf.SetLongValue(docData.NodeTimestamp); doc.Add(nf); nf = new NumericField(LucObject.FieldName.VersionTimestamp, Field.Store.YES, true); nf.SetLongValue(docData.VersionTimestamp); doc.Add(nf); // custom fields if (info.HasCustomField) { var customFields = CustomIndexFieldManager.GetFields(info, docData); if (customFields != null) foreach (var field in customFields) doc.Add(field); } return doc; }
public void FinalizeTextExtracting(object data, IndexDocumentData indexDocument) { }
private static void CreateTreeActivityAndExecute(IndexingActivityType type, string path, int nodeId, bool moveOrRename, IndexDocumentData indexDocumentData) { ExecuteActivity(CreateTreeActivity(type, path, nodeId, moveOrRename, indexDocumentData)); }
public STT.Task FinalizeTextExtractingAsync(object data, IndexDocumentData indexDocument, CancellationToken cancellationToken) { return(STT.Task.CompletedTask); }
private static Exception SaveNodeDataTransactional(Node node, NodeSaveSettings settings, IIndexPopulator populator, string originalPath, string newPath) { IndexDocumentData indexDocument = null; bool hasBinary = false; var data = node.Data; var isNewNode = data.Id == 0; NodeDataParticipant participant = null; var msg = "Saving Node#" + node.Id + ", " + node.ParentPath + "/" + node.Name; var isLocalTransaction = !TransactionScope.IsActive; using (var op = SnTrace.Database.StartOperation(msg)) { if (isLocalTransaction) { TransactionScope.Begin(); } try { // collect data for populator var populatorData = populator.BeginPopulateNode(node, settings, originalPath, newPath); data.CreateSnapshotData(); participant = new NodeDataParticipant { Data = data, Settings = settings, IsNewNode = isNewNode }; TransactionScope.Participate(participant); if (settings.NodeHead != null) { settings.LastMajorVersionIdBefore = settings.NodeHead.LastMajorVersionId; settings.LastMinorVersionIdBefore = settings.NodeHead.LastMinorVersionId; } int lastMajorVersionId, lastMinorVersionId; DataProvider.Current.SaveNodeData(data, settings, out lastMajorVersionId, out lastMinorVersionId); settings.LastMajorVersionIdAfter = lastMajorVersionId; settings.LastMinorVersionIdAfter = lastMinorVersionId; // here we re-create the node head to insert it into the cache and refresh the version info); if (lastMajorVersionId > 0 || lastMinorVersionId > 0) { var head = NodeHead.CreateFromNode(node, lastMinorVersionId, lastMajorVersionId); if (MustCache(node.NodeType)) { // participate cache items var idKey = CreateNodeHeadIdCacheKey(head.Id); var participant2 = new InsertCacheParticipant { CacheKey = idKey }; TransactionScope.Participate(participant2); var pathKey = CreateNodeHeadPathCacheKey(head.Path); var participant3 = new InsertCacheParticipant { CacheKey = pathKey }; TransactionScope.Participate(participant3); CacheNodeHead(head, idKey, pathKey); } node.RefreshVersionInfo(head); if (!settings.DeletableVersionIds.Contains(node.VersionId)) { // Elevation: we need to create the index document with full // control to avoid field access errors (indexing must be independent // from the current users permissions). using (new SystemAccount()) { indexDocument = SaveIndexDocument(node, true, isNewNode, out hasBinary); } } } if (isLocalTransaction) { TransactionScope.Commit(); } // populate index only if it is enabled on this content (e.g. preview images will be skipped) using (var op2 = SnTrace.Index.StartOperation("Indexing node")) { if (node.IsIndexingEnabled) { using (new SystemAccount()) populator.CommitPopulateNode(populatorData, indexDocument); } if (indexDocument != null && hasBinary) { using (new SystemAccount()) { indexDocument = SaveIndexDocument(node, indexDocument); populator.FinalizeTextExtracting(populatorData, indexDocument); } } op2.Successful = true; } } catch (NodeIsOutOfDateException) { RemoveFromCache(participant); throw; } catch (System.Data.Common.DbException dbe) { if (isLocalTransaction && IsDeadlockException(dbe)) { return(dbe); } throw SavingExceptionHelper(data, dbe); } catch (Exception e) { var ee = SavingExceptionHelper(data, e); if (ee == e) { throw; } else { throw ee; } } finally { if (isLocalTransaction && TransactionScope.IsActive) { TransactionScope.Rollback(); } } op.Successful = true; } return(null); }