diff --git a/sdk/search/Azure.Search.Documents/api/Azure.Search.Documents.netstandard2.0.cs b/sdk/search/Azure.Search.Documents/api/Azure.Search.Documents.netstandard2.0.cs index 1122464ff8af6..8bbc7b0782bcf 100644 --- a/sdk/search/Azure.Search.Documents/api/Azure.Search.Documents.netstandard2.0.cs +++ b/sdk/search/Azure.Search.Documents/api/Azure.Search.Documents.netstandard2.0.cs @@ -32,7 +32,6 @@ public SearchClient(System.Uri endpoint, string indexName, Azure.AzureKeyCredent public virtual string ServiceName { get { throw null; } } public virtual Azure.Response Autocomplete(string searchText, string suggesterName, Azure.Search.Documents.AutocompleteOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> AutocompleteAsync(string searchText, string suggesterName, Azure.Search.Documents.AutocompleteOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Search.Documents.SearchIndexingBufferedSender CreateIndexingBufferedSender(Azure.Search.Documents.SearchIndexingBufferedSenderOptions options = null) { throw null; } public virtual Azure.Response DeleteDocuments(string keyName, System.Collections.Generic.IEnumerable keyValues, Azure.Search.Documents.IndexDocumentsOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> DeleteDocumentsAsync(string keyName, System.Collections.Generic.IEnumerable keyValues, Azure.Search.Documents.IndexDocumentsOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> DeleteDocumentsAsync(System.Collections.Generic.IEnumerable documents, Azure.Search.Documents.IndexDocumentsOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } diff --git a/sdk/search/Azure.Search.Documents/src/SearchClient.cs b/sdk/search/Azure.Search.Documents/src/SearchClient.cs index 31c16a4de19f0..8725634add35a 100644 --- a/sdk/search/Azure.Search.Documents/src/SearchClient.cs +++ b/sdk/search/Azure.Search.Documents/src/SearchClient.cs @@ -1899,26 +1899,5 @@ public virtual async Task> DeleteDocumentsAsync( } } #endregion Index Documents Conveniences - - /// - /// Creates a new that - /// can be used to index search documents with intelligent batching, - /// automatic flushing, and retries for failed indexing actions. - /// - /// - /// The .NET type that maps to the index schema. Instances of this - /// type can be retrieved as documents from the index. You can use - /// for dynamic documents. - /// - /// - /// The to - /// customize the sender's behavior. - /// - /// - /// A new . - /// - public virtual SearchIndexingBufferedSender CreateIndexingBufferedSender( - SearchIndexingBufferedSenderOptions options = null) => - new SearchIndexingBufferedSender(this, options); } } diff --git a/sdk/search/Azure.Search.Documents/tests/Batching/BatchingTests.cs b/sdk/search/Azure.Search.Documents/tests/Batching/BatchingTests.cs index 9ea7f05335530..9ced9148b8ce3 100644 --- a/sdk/search/Azure.Search.Documents/tests/Batching/BatchingTests.cs +++ b/sdk/search/Azure.Search.Documents/tests/Batching/BatchingTests.cs @@ -191,6 +191,10 @@ public override async Task> IndexDocumentsAsync CreateIndexingBufferedSender( + SearchIndexingBufferedSenderOptions options = null) => + new SearchIndexingBufferedSender(this, options); } public BatchingSearchClient GetBatchingSearchClient(SearchResources resources) @@ -209,7 +213,7 @@ public BatchingSearchClient GetBatchingSearchClient(SearchResources resources) public async Task Champion_OneShotUpload() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); SimpleDocument[] data = SimpleDocument.GetDocuments(50000); // Wrap in a block so we DisposeAsync before getting the Count below @@ -228,7 +232,7 @@ public async Task Champion_OneShotUpload() public async Task Champion_ContinueAddingWhileSending() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); SimpleDocument[] data = SimpleDocument.GetDocuments(1000); // Wrap in a block so we DisposeAsync before getting the Count below @@ -253,7 +257,7 @@ public async Task Champion_ContinueAddingWhileSending() public async Task Champion_ManualFlushing() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); SimpleDocument[] data = SimpleDocument.GetDocuments(1000); await using SearchIndexingBufferedSender indexer = @@ -275,7 +279,7 @@ public async Task Champion_ManualFlushing() public async Task Champion_FlushAfterInterval() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); SimpleDocument[] data = SimpleDocument.GetDocuments(20); await using SearchIndexingBufferedSender indexer = @@ -297,7 +301,7 @@ public async Task Champion_FlushAfterInterval() public async Task Champion_FineGrainedErrors() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); SimpleDocument[] data = SimpleDocument.GetDocuments(1000); // Don't touch the failures outside of the event handler until @@ -333,7 +337,7 @@ public async Task Champion_FineGrainedErrors() public async Task Champion_BasicCheckpointing() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); SimpleDocument[] data = SimpleDocument.GetDocuments(1000); await using SearchIndexingBufferedSender indexer = @@ -381,7 +385,7 @@ public async Task Champion_BasicCheckpointing() public async Task KeyFieldAccessor_Custom() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); SimpleDocument[] data = SimpleDocument.GetDocuments(10); bool customAccessorInvoked = false; @@ -427,7 +431,7 @@ public async Task KeyFieldAccessor_FieldBuilder() LessSimpleDocument[] data = LessSimpleDocument.GetDocuments(10); await using SearchIndexingBufferedSender indexer = - client.CreateIndexingBufferedSender(); + new SearchIndexingBufferedSender(client); AssertNoFailures(indexer); await indexer.UploadDocumentsAsync(data); await indexer.FlushAsync(); @@ -452,7 +456,7 @@ public static UnbuildableDocument[] GetDocuments(int count) => public async Task KeyFieldAccessor_FetchIndex() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); UnbuildableDocument[] data = UnbuildableDocument.GetDocuments(10); await using SearchIndexingBufferedSender indexer = @@ -467,7 +471,7 @@ public async Task KeyFieldAccessor_FetchIndex() public async Task KeyFieldAccessor_Error() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); Hotel[] data = SearchResources.TestDocuments; await using SearchIndexingBufferedSender indexer = @@ -489,7 +493,7 @@ public async Task KeyFieldAccessor_Error() public async Task AutoFlush_PartialBatch() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); SimpleDocument[] data = SimpleDocument.GetDocuments(BatchSize / 2); await using SearchIndexingBufferedSender indexer = @@ -512,7 +516,7 @@ public async Task AutoFlush_PartialBatch() public async Task AutoFlush_FullBatch() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); SimpleDocument[] data = SimpleDocument.GetDocuments((int)(BatchSize * 1.5)); await using SearchIndexingBufferedSender indexer = @@ -535,7 +539,7 @@ public async Task AutoFlush_FullBatch() public async Task AutoFlush_MultipleBatches() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); SimpleDocument[] data = SimpleDocument.GetDocuments((int)(BatchSize * 3.5)); await using SearchIndexingBufferedSender indexer = @@ -631,7 +635,7 @@ public async Task AutoFlushInterval_TinyInterval() public async Task AutoFlushInterval_DoesNotFire(int? interval) { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); SimpleDocument[] data = SimpleDocument.GetDocuments(BatchSize / 2); await using SearchIndexingBufferedSender indexer = @@ -655,7 +659,7 @@ public async Task AutoFlushInterval_DoesNotFire(int? interval) public async Task Flush_SubmitsEverything() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); SimpleDocument[] data = SimpleDocument.GetDocuments((int)(BatchSize * 1.5)); await using SearchIndexingBufferedSender indexer = @@ -675,7 +679,7 @@ public async Task Flush_SubmitsEverything() public async Task Flush_Blocks() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); SimpleDocument[] data = SimpleDocument.GetDocuments((int)(BatchSize * 1.5)); await using SearchIndexingBufferedSender indexer = @@ -702,7 +706,7 @@ public async Task Flush_Blocks() public async Task Dispose_Flushes() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); SimpleDocument[] data = SimpleDocument.GetDocuments((int)(BatchSize * 1.5)); await using SearchIndexingBufferedSender indexer = @@ -722,7 +726,7 @@ public async Task Dispose_Flushes() public async Task Dispose_Blocks() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); SimpleDocument[] data = SimpleDocument.GetDocuments((int)(BatchSize * 1.5)); await using SearchIndexingBufferedSender indexer = @@ -746,7 +750,7 @@ public async Task Dispose_Blocks() public async Task Dispose_DoubleDisposeIsSafe() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); SimpleDocument[] data = SimpleDocument.GetDocuments((int)(BatchSize * 1.5)); await using SearchIndexingBufferedSender indexer = @@ -767,7 +771,7 @@ public async Task Dispose_DoubleDisposeIsSafe() public async Task Dispose_ThrowsAfterDispose() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); SimpleDocument[] data = SimpleDocument.GetDocuments((int)(BatchSize * 1.5)); await using SearchIndexingBufferedSender indexer = @@ -788,7 +792,7 @@ public async Task Dispose_ThrowsAfterDispose() public async Task Dispose_UndisposedNoCrash() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); SimpleDocument[] data = SimpleDocument.GetDocuments((int)(BatchSize * 1.5)); SearchIndexingBufferedSender indexer = @@ -807,7 +811,7 @@ public async Task Dispose_UndisposedNoCrash() public async Task Convenience_Delete() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); SimpleDocument[] data = SimpleDocument.GetDocuments((int)(BatchSize * 1.5)); await using SearchIndexingBufferedSender indexer = @@ -823,7 +827,7 @@ public async Task Convenience_Delete() public async Task Convenience_Merge() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); SimpleDocument[] data = SimpleDocument.GetDocuments((int)(BatchSize * 1.5)); await using SearchIndexingBufferedSender indexer = @@ -839,7 +843,7 @@ public async Task Convenience_Merge() public async Task Convenience_MergeOrUpload() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); SimpleDocument[] data = SimpleDocument.GetDocuments((int)(BatchSize * 1.5)); await using SearchIndexingBufferedSender indexer = @@ -855,7 +859,7 @@ public async Task Convenience_MergeOrUpload() public async Task Convenience_Upload() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); SimpleDocument[] data = SimpleDocument.GetDocuments((int)(BatchSize * 1.5)); await using SearchIndexingBufferedSender indexer = @@ -871,7 +875,7 @@ public async Task Convenience_Upload() public async Task Convenience_None() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); SimpleDocument[] data = SimpleDocument.GetDocuments(3); await using SearchIndexingBufferedSender indexer = @@ -893,7 +897,7 @@ public async Task Convenience_None() public async Task Notifications_Added() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); SimpleDocument[] data = SimpleDocument.GetDocuments((int)(BatchSize * 1.5)); await using SearchIndexingBufferedSender indexer = @@ -910,7 +914,7 @@ public async Task Notifications_Added() public async Task Notifications_Sent() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); SimpleDocument[] data = SimpleDocument.GetDocuments((int)(BatchSize * 1.5)); await using SearchIndexingBufferedSender indexer = @@ -928,7 +932,7 @@ public async Task Notifications_Sent() public async Task Notifications_Completed() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); SimpleDocument[] data = SimpleDocument.GetDocuments((int)(BatchSize * 1.5)); await using SearchIndexingBufferedSender indexer = @@ -946,7 +950,7 @@ public async Task Notifications_Completed() public async Task Notifications_Failed() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); SimpleDocument[] data = SimpleDocument.GetDocuments((int)(BatchSize * 1.5)); await using SearchIndexingBufferedSender indexer = @@ -964,7 +968,7 @@ public async Task Notifications_Failed() public async Task Notifications_ExceptionsGetSwallowed() { await using SearchResources resources = await SearchResources.CreateWithEmptyIndexAsync(this); - SearchClient client = resources.GetSearchClient(); + BatchingSearchClient client = GetBatchingSearchClient(resources); SimpleDocument[] data = SimpleDocument.GetDocuments(BatchSize); await using SearchIndexingBufferedSender indexer =