Esempio n. 1
0
        private static async Task DeleteDocumentsInternal(
            SearchIndexingBufferedSender <SearchDocument> indexer,
            string keyFieldName,
            IEnumerable <string> documentKeys,
            bool async,
            CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(indexer, nameof(indexer));
            Argument.AssertNotNull(keyFieldName, nameof(keyFieldName));
            Argument.AssertNotNull(documentKeys, nameof(documentKeys));

            var batch = IndexDocumentsBatch.Delete <SearchDocument>(
                documentKeys.Select(k => new SearchDocument {
                [keyFieldName] = k
            }));

            if (async)
            {
                await indexer.IndexDocumentsAsync(batch, cancellationToken).ConfigureAwait(false);
            }
            else
            {
                indexer.IndexDocuments(batch, cancellationToken);
            }
        }