public InMemoryIndexDocumentChangeFeed(string[] documentIds, IndexDocumentChangeType changeType, long take) { DocumentIds = documentIds ?? throw new ArgumentNullException(nameof(documentIds)); ChangeType = changeType; TotalCount = documentIds.Length; Take = take; }
protected virtual async Task <IndexingResult> ProcessDocumentsAsync(IndexDocumentChangeType changeType, string[] changedIds, BatchIndexingOptions batchOptions, ICancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); IndexingResult result = null; if (changeType == IndexDocumentChangeType.Deleted) { result = await DeleteDocumentsAsync(batchOptions.DocumentType, changedIds); } else if (changeType is IndexDocumentChangeType.Modified or IndexDocumentChangeType.Created) { var documents = await GetDocumentsAsync(changedIds, batchOptions.PrimaryDocumentBuilder, batchOptions.SecondaryDocumentBuilders, cancellationToken); if (batchOptions.Reindex && _searchProvider is ISupportIndexSwap supportIndexSwapProvider) { result = await supportIndexSwapProvider.IndexWithBackupAsync(batchOptions.DocumentType, documents); } else { result = await _searchProvider.IndexAsync(batchOptions.DocumentType, documents); } } return(result); }
protected virtual async Task <IndexingResult> ProcessDocumentsAsync(IndexDocumentChangeType changeType, IList <string> documentIds, BatchIndexingOptions batchOptions, ICancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); IndexingResult result = null; if (changeType == IndexDocumentChangeType.Deleted) { result = await DeleteDocumentsAsync(batchOptions.DocumentType, documentIds.ToArray()); } else if (changeType == IndexDocumentChangeType.Modified) { result = await IndexDocumentsAsync(batchOptions.DocumentType, documentIds, batchOptions.PrimaryDocumentBuilder, batchOptions.SecondaryDocumentBuilders, cancellationToken); } return(result); }