Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions sdk/search/Azure.Search.Documents/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## 1.0.0-preview.4 (Unreleased)

### Breaking Changes

- Moved data source, index, indexer, skillset, and synonym map operations to separate clients obtained from `SearchServiceClient`.
- Renamed `SearchServiceClient.GetServiceStatistics` and `SearchServiceClient.GetServiceStatisticsAsync` to `SearchServiceClient.GetStatistics` and `SearchServiceClient.GetStatisticsAsync`, respectively.

## 1.0.0-preview.3 (2020-05-05)

Expand Down
2 changes: 1 addition & 1 deletion sdk/search/Azure.Search.Documents/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ SearchIndex index = new SearchIndex("hotels")
}
};

client.CreateIndex(index);
client.GetSearchIndexClient().CreateIndex(index);
```

### Adding documents to your index
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ AzureKeyCredential credential = new AzureKeyCredential(
SearchServiceClient search = new SearchServiceClient(endpoint, credential);

// Perform an operation
Response<SearchServiceStatistics> stats = search.GetServiceStatistics();
Response<SearchServiceStatistics> stats = search.GetStatistics();
Console.WriteLine($"You are using {stats.Value.Counters.IndexCounter.Usage} indexes.");
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ AzureKeyCredential credential = new AzureKeyCredential(
SearchServiceClient search = new SearchServiceClient(endpoint, credential);

// Perform an operation
Response<SearchServiceStatistics> stats = await search.GetServiceStatisticsAsync();
Response<SearchServiceStatistics> stats = await search.GetStatisticsAsync();
Console.WriteLine($"You are using {stats.Value.Counters.IndexCounter.Usage} indexes.");
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ AzureKeyCredential credential = new AzureKeyCredential(
SearchServiceClient search = new SearchServiceClient(endpoint, credential);

// Get and report the Search Service statistics
Response<SearchServiceStatistics> stats = await search.GetServiceStatisticsAsync();
Response<SearchServiceStatistics> stats = await search.GetStatisticsAsync();
Console.WriteLine($"You are using {stats.Value.Counters.IndexCounter.Usage} of {stats.Value.Counters.IndexCounter.Quota} indexes.");
```
712 changes: 712 additions & 0 deletions sdk/search/Azure.Search.Documents/src/Indexes/SearchIndexClient.cs

Large diffs are not rendered by default.

712 changes: 712 additions & 0 deletions sdk/search/Azure.Search.Documents/src/Indexes/SearchIndexerClient.cs

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

529 changes: 529 additions & 0 deletions sdk/search/Azure.Search.Documents/src/Indexes/SynonymMapClient.cs

Large diffs are not rendered by default.

2,857 changes: 56 additions & 2,801 deletions sdk/search/Azure.Search.Documents/src/SearchServiceClient.cs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions sdk/search/Azure.Search.Documents/tests/Samples/HelloWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public async Task CreateClient()
/*@@*/ search = InstrumentClient(new SearchServiceClient(endpoint, credential, GetSearchClientOptions()));

// Perform an operation
Response<SearchServiceStatistics> stats = search.GetServiceStatistics();
Response<SearchServiceStatistics> stats = search.GetStatistics();
Console.WriteLine($"You are using {stats.Value.Counters.IndexCounter.Usage} indexes.");
#endregion Snippet:Azure_Search_Tests_Samples_CreateClient

Expand All @@ -64,7 +64,7 @@ public async Task CreateClientAsync()
/*@@*/ search = InstrumentClient(new SearchServiceClient(endpoint, credential, GetSearchClientOptions()));

// Perform an operation
Response<SearchServiceStatistics> stats = await search.GetServiceStatisticsAsync();
Response<SearchServiceStatistics> stats = await search.GetStatisticsAsync();
Console.WriteLine($"You are using {stats.Value.Counters.IndexCounter.Usage} indexes.");
#endregion Snippet:Azure_Search_Tests_Samples_CreateClientAsync

Expand Down Expand Up @@ -143,7 +143,7 @@ public async Task GetStatisticsAsync()
/*@@*/ search = InstrumentClient(new SearchServiceClient(endpoint, credential, GetSearchClientOptions()));

// Get and report the Search Service statistics
Response<SearchServiceStatistics> stats = await search.GetServiceStatisticsAsync();
Response<SearchServiceStatistics> stats = await search.GetStatisticsAsync();
Console.WriteLine($"You are using {stats.Value.Counters.IndexCounter.Usage} of {stats.Value.Counters.IndexCounter.Quota} indexes.");
#endregion Snippet:Azure_Search_Tests_Samples_GetStatisticsAsync
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/search/Azure.Search.Documents/tests/Samples/Readme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public async Task CreateIndex()
}
};

client.CreateIndex(index);
client.GetSearchIndexClient().CreateIndex(index);
#endregion Snippet:Azure_Search_Tests_Samples_Readme_CreateIndex
}

Expand Down
34 changes: 18 additions & 16 deletions sdk/search/Azure.Search.Documents/tests/SearchServiceClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Azure.Core;
using Azure.Core.Pipeline;
using Azure.Core.TestFramework;
using Azure.Search.Documents.Indexes;
using Azure.Search.Documents.Models;
using NUnit.Framework;

Expand Down Expand Up @@ -85,7 +86,7 @@ public async Task ClientRequestIdRountrips()
SearchServiceClient client = resources.GetServiceClient();
Guid id = Recording.Random.NewGuid();
Response<SearchServiceStatistics> response =
await client.GetServiceStatisticsAsync(
await client.GetStatisticsAsync(
new SearchRequestOptions { ClientRequestId = id });

Assert.AreEqual(id.ToString(), response.GetRawResponse().ClientRequestId);
Expand Down Expand Up @@ -123,7 +124,7 @@ public async Task GetServiceStatistics()
await using SearchResources resources = await SearchResources.GetSharedHotelsIndexAsync(this);

SearchServiceClient client = resources.GetServiceClient();
Response<SearchServiceStatistics> response = await client.GetServiceStatisticsAsync();
Response<SearchServiceStatistics> response = await client.GetStatisticsAsync();
Assert.AreEqual(200, response.GetRawResponse().Status);
Assert.IsNotNull(response.Value);
Assert.IsNotNull(response.Value.Counters);
Expand All @@ -143,7 +144,7 @@ public async Task GetServiceStatistics()
public void CreateIndexParameterValidation()
{
var endpoint = new Uri($"https://my-svc-name.search.windows.net");
var service = new SearchServiceClient(endpoint, new AzureKeyCredential("fake"));
var service = new SearchServiceClient(endpoint, new AzureKeyCredential("fake")).GetSearchIndexClient();

ArgumentException ex = Assert.Throws<ArgumentNullException>(() => service.CreateIndex(null));
Assert.AreEqual("index", ex.ParamName);
Expand All @@ -161,7 +162,7 @@ public async Task CreateIndex()
SearchIndex expectedIndex = SearchResources.GetHotelIndex(resources.IndexName);

SearchServiceClient client = resources.GetServiceClient();
SearchIndex actualIndex = await client.CreateIndexAsync(expectedIndex);
SearchIndex actualIndex = await client.GetSearchIndexClient().CreateIndexAsync(expectedIndex);

Assert.AreEqual(expectedIndex.Name, actualIndex.Name);
Assert.That(actualIndex.Fields, Is.EqualTo(expectedIndex.Fields).Using(SearchFieldComparer.Shared));
Expand All @@ -180,7 +181,7 @@ public async Task UpdateIndex()
SearchIndex initialIndex = SearchResources.GetHotelIndex(resources.IndexName);

SearchServiceClient client = resources.GetServiceClient();
SearchIndex createdIndex = await client.CreateIndexAsync(initialIndex);
SearchIndex createdIndex = await client.GetSearchIndexClient().CreateIndexAsync(initialIndex);

string analyzerName = "asciiTags";

Expand Down Expand Up @@ -209,7 +210,7 @@ public async Task UpdateIndex()
IsFilterable = true,
});

SearchIndex updatedIndex = await client.CreateOrUpdateIndexAsync(
SearchIndex updatedIndex = await client.GetSearchIndexClient().CreateOrUpdateIndexAsync(
createdIndex,
allowIndexDowntime: true,
onlyIfUnchanged: true,
Expand All @@ -229,7 +230,7 @@ public async Task UpdateIndex()
public void GetIndexParameterValidation()
{
var endpoint = new Uri($"https://my-svc-name.search.windows.net");
var service = new SearchServiceClient(endpoint, new AzureKeyCredential("fake"));
var service = new SearchServiceClient(endpoint, new AzureKeyCredential("fake")).GetSearchIndexClient();

ArgumentException ex = Assert.Throws<ArgumentNullException>(() => service.GetIndex(null));
Assert.AreEqual("indexName", ex.ParamName);
Expand All @@ -244,7 +245,7 @@ public async Task GetIndex()
await using SearchResources resources = await SearchResources.CreateWithHotelsIndexAsync(this);

SearchServiceClient client = resources.GetServiceClient();
SearchIndex index = await client.GetIndexAsync(resources.IndexName);
SearchIndex index = await client.GetSearchIndexClient().GetIndexAsync(resources.IndexName);

// TODO: Replace with comparison of actual SearchIndex once test framework uses Azure.Search.Documents instead.
Assert.AreEqual(resources.IndexName, index.Name);
Expand All @@ -259,7 +260,7 @@ public async Task GetIndexes()
SearchServiceClient client = resources.GetServiceClient();

bool found = false;
await foreach (SearchIndex index in client.GetIndexesAsync())
await foreach (SearchIndex index in client.GetSearchIndexClient().GetIndexesAsync())
{
found |= string.Equals(resources.IndexName, index.Name, StringComparison.InvariantCultureIgnoreCase);
}
Expand All @@ -274,7 +275,7 @@ public async Task GetIndexesNextPageThrows()
await using SearchResources resources = await SearchResources.GetSharedHotelsIndexAsync(this);

SearchServiceClient client = resources.GetServiceClient();
AsyncPageable<SearchIndex> pageable = client.GetIndexesAsync();
AsyncPageable<SearchIndex> pageable = client.GetSearchIndexClient().GetIndexesAsync();

string continuationToken = Recording.GenerateId();
IAsyncEnumerator<Page<SearchIndex>> e = pageable.AsPages(continuationToken).GetAsyncEnumerator();
Expand All @@ -297,7 +298,7 @@ public async Task CreateAzureBlobIndexer()
resources.StorageAccountConnectionString,
new SearchIndexerDataContainer(resources.BlobContainerName));

SearchIndexerDataSource actualSource = await serviceClient.CreateDataSourceAsync(
SearchIndexerDataSource actualSource = await serviceClient.GetSearchIndexerDataSourceClient().CreateDataSourceAsync(
dataSource,
new SearchRequestOptions { ClientRequestId = Recording.Random.NewGuid() });

Expand All @@ -306,21 +307,22 @@ public async Task CreateAzureBlobIndexer()
dataSource.Name,
resources.IndexName);

SearchIndexer actualIndexer = await serviceClient.CreateIndexerAsync(
SearchIndexerClient indexerClient = serviceClient.GetSearchIndexerClient();
SearchIndexer actualIndexer = await indexerClient.CreateIndexerAsync(
indexer,
new SearchRequestOptions { ClientRequestId = Recording.Random.NewGuid() });

// Update the indexer.
actualIndexer.Description = "Updated description";
await serviceClient.CreateOrUpdateIndexerAsync(
await indexerClient.CreateOrUpdateIndexerAsync(
actualIndexer,
onlyIfUnchanged: true,
new SearchRequestOptions { ClientRequestId = Recording.Random.NewGuid() });

await WaitForIndexingAsync(serviceClient, actualIndexer.Name);

// Run the indexer.
await serviceClient.RunIndexerAsync(
await indexerClient.RunIndexerAsync(
indexer.Name,
new SearchRequestOptions { ClientRequestId = Recording.Random.NewGuid() });

Expand All @@ -343,7 +345,7 @@ public async Task CrudSynonymMaps()

string synonymMapName = Recording.Random.GetName();

SearchServiceClient client = resources.GetServiceClient();
SynonymMapClient client = resources.GetServiceClient().GetSynonymMapClient();

SynonymMap createdMap = await client.CreateSynonymMapAsync(new SynonymMap(synonymMapName, "msft=>Microsoft"));
Assert.AreEqual(synonymMapName, createdMap.Name);
Expand Down Expand Up @@ -403,7 +405,7 @@ private async Task WaitForIndexingAsync(
{
await DelayAsync(delay, cancellationToken: cts.Token);

SearchIndexerStatus status = await client.GetIndexerStatusAsync(
SearchIndexerStatus status = await client.GetSearchIndexerClient().GetIndexerStatusAsync(
indexerName,
new SearchRequestOptions { ClientRequestId = Recording.Random.NewGuid() },
cts.Token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
using System.Threading;
using System.Threading.Tasks;
using Azure.Core.TestFramework;
using Azure.Search.Documents.Indexes;
using Azure.Search.Documents.Models;
using Azure.Storage.Blobs;
using NUnit.Framework;
using NUnit.Framework.Internal;

namespace Azure.Search.Documents.Tests
{
Expand Down Expand Up @@ -283,7 +283,7 @@ private async Task DeleteIndexAsync()
{
if (RequiresCleanup && !string.IsNullOrEmpty(IndexName))
{
SearchServiceClient client = GetServiceClient();
SearchIndexClient client = GetServiceClient().GetSearchIndexClient();
await client.DeleteIndexAsync(IndexName);
RequiresCleanup = false;
}
Expand Down Expand Up @@ -315,7 +315,7 @@ private async Task<SearchResources> CreateSearchServiceAndIndexAsync()
// Generate a random Index Name
IndexName = Random.GetName(8);

SearchServiceClient client = new SearchServiceClient(Endpoint, new AzureKeyCredential(PrimaryApiKey));
SearchIndexClient client = new SearchServiceClient(Endpoint, new AzureKeyCredential(PrimaryApiKey)).GetSearchIndexClient();
await client.CreateIndexAsync(GetHotelIndex(IndexName));

RequiresCleanup = true;
Expand Down