public async Task UpdateAsync <T>(T item, IGraphRequestContext graphRequestContext) where T : class { var client = Get <T>(graphRequestContext); var batch = IndexDocumentsBatch.Create(IndexDocumentsAction.Merge(item)); await client.IndexDocumentsAsync(batch); }
public async Task Index() { await using SearchResources resources = await SearchResources.CreateWithEmptyHotelsIndexAsync(this); SearchClient client = resources.GetQueryClient(); try { #region Snippet:Azure_Search_Tests_Samples_Readme_Index IndexDocumentsBatch <Hotel> batch = IndexDocumentsBatch.Create( IndexDocumentsAction.Upload(new Hotel { Id = "783", Name = "Upload Inn" }), IndexDocumentsAction.Merge(new Hotel { Id = "12", Name = "Renovated Ranch" })); IndexDocumentsOptions options = new IndexDocumentsOptions { ThrowOnAnyError = true }; client.IndexDocuments(batch, options); #endregion Snippet:Azure_Search_Tests_Samples_Readme_Index } catch (RequestFailedException) { // Ignore the non-existent merge failure } }
public void UpdateCustomerData(CustomerIndex customerToUpdate) { IndexDocumentsBatch <CustomerIndex> batch = IndexDocumentsBatch.Create(IndexDocumentsAction.Merge(customerToUpdate)); IndexDocumentsOptions idxoptions = new IndexDocumentsOptions { ThrowOnAnyError = true }; _qryClient.IndexDocuments(batch, idxoptions); }