Example #1
0
 public InMemoryIndexDocumentChangeFeed(string[] documentIds, IndexDocumentChangeType changeType, long take)
 {
     DocumentIds = documentIds ?? throw new ArgumentNullException(nameof(documentIds));
     ChangeType  = changeType;
     TotalCount  = documentIds.Length;
     Take        = take;
 }
Example #2
0
        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);
        }
Example #3
0
        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);
        }