Skip to content

Commit

Permalink
Fix SearchDocument (#12610)
Browse files Browse the repository at this point in the history
* Fix SearchDocument
* PR Feedback
* PR Feedback - Change from Array to IReadOnlyList
  • Loading branch information
tg-msft authored Jun 9, 2020
1 parent 35aeb63 commit e95f06f
Show file tree
Hide file tree
Showing 84 changed files with 4,938 additions and 5,121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ public PointGeometry(GeometryPosition position, GeometryProperties properties):
/// </summary>
public GeometryPosition Position { get; }
}
}
}
6 changes: 6 additions & 0 deletions sdk/search/Azure.Search.Documents.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Core", "..\core\Azure
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Core.TestFramework", "..\core\Azure.Core.TestFramework\src\Azure.Core.TestFramework.csproj", "{06C87DE1-98A8-418E-AF01-FEFF9CFFA788}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Core.Experimental", "..\core\Azure.Core.Experimental\src\Azure.Core.Experimental.csproj", "{32F92309-FF56-4E48-81FF-ADC7318F6DA5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -33,6 +35,10 @@ Global
{06C87DE1-98A8-418E-AF01-FEFF9CFFA788}.Debug|Any CPU.Build.0 = Debug|Any CPU
{06C87DE1-98A8-418E-AF01-FEFF9CFFA788}.Release|Any CPU.ActiveCfg = Release|Any CPU
{06C87DE1-98A8-418E-AF01-FEFF9CFFA788}.Release|Any CPU.Build.0 = Release|Any CPU
{32F92309-FF56-4E48-81FF-ADC7318F6DA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{32F92309-FF56-4E48-81FF-ADC7318F6DA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{32F92309-FF56-4E48-81FF-ADC7318F6DA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{32F92309-FF56-4E48-81FF-ADC7318F6DA5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
5 changes: 4 additions & 1 deletion sdk/search/Azure.Search.Documents/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Release History

## 1.0.0-preview.4 (2020-05-09)
## 1.0.0-preview.4 (2020-06-09)

### Added

- Referencing `Azure.Core.Experimental` which brings new spatial types and custom serializers.
- Added `SearchClientBuilderExtensions` to integrate with ASP.NET Core.
- Added `SearchModelFactory` to mock output model types.

Expand All @@ -21,6 +22,8 @@
- Renamed methods on `SearchIndexerClient` matching "\*DataSource" to "\*DataSourceConnection".
- Split `SearchServiceClient` into `SearchIndexClient` for managing indexes, and `SearchIndexerClient` for managing indexers, both of which are now in `Azure.Search.Documents.Indexes`.
- `SearchClient.IndexDocuments` now throws an `AggregateException` wrapping all the `RequestFailedException`s in the batch.
- Removed `dynamic` support from `SearchDocument` for the time being.


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

Expand Down
34 changes: 34 additions & 0 deletions sdk/search/Azure.Search.Documents/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,4 +1,38 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!-- Azure.Core.Experimental feature flags -->
<PropertyGroup>
<!-- Enable everything by default -->
<UseAzureCoreExperimental Condition="'$(UseAzureCoreExperimental)' == ''">true</UseAzureCoreExperimental>

<!-- Use Azure.Core.Experimental's Spatial features -->
<!-- (Note: a number of tests will need re-recording if you disable) -->
<UseAzureCoreExperimentalSpatial Condition="'$(UseAzureCoreExperimentalSpatial)' == ''">$(UseAzureCoreExperimental)</UseAzureCoreExperimentalSpatial>
<DefineConstants Condition="'$(UseAzureCoreExperimentalSpatial)' == 'true'">EXPERIMENTAL_SPATIAL;$(DefineConstants)</DefineConstants>

<!-- Use Azure.Core.Experimental's ObjectSerializer features -->
<UseAzureCoreExperimentalSerializer Condition="'$(UseAzureCoreExperimentalSerializer)' == ''">$(UseAzureCoreExperimental)</UseAzureCoreExperimentalSerializer>
<DefineConstants Condition="'$(UseAzureCoreExperimentalSerializer)' == 'true'">EXPERIMENTAL_SERIALIZER;$(DefineConstants)</DefineConstants>

<!-- Use Azure.Core.Experimental's DynamicData features (stubbed out in Search for now) -->
<UseAzureCoreExperimentalDynamic Condition="'$(UseAzureCoreExperimentalDynamic)' == ''">false</UseAzureCoreExperimentalDynamic>
<DefineConstants Condition="'$(UseAzureCoreExperimentalDynamic)' == 'true'">EXPERIMENTAL_DYNAMIC;$(DefineConstants)</DefineConstants>

<!-- Use a Package or Project reference to Azure.Core.Experimental -->
<AddExperimentalReference Condition="('$(UseAzureCoreExperimentalSpatial)' == 'true') OR ('$(UseAzureCoreExperimentalSerializer)' == 'true') OR ('$(UseAzureCoreExperimentalSerializer)' == 'true')">true</AddExperimentalReference>
<UseExperimentalProjectReference Condition="'$(UseExperimentalProjectReference)' == ''">$(UseProjectReferenceToAzureClients)</UseExperimentalProjectReference>
</PropertyGroup>

<!-- Add a reference to Azure.Core.Experimental -->
<ItemGroup Condition="'$(AddExperimentalReference)' == 'true' AND '$(IsTestProject)' != 'true'">
<ProjectReference
Condition="'$(UseExperimentalProjectReference)' == 'true'"
Include="$(MSBuildThisFileDirectory)..\..\core\Azure.Core.Experimental\src\Azure.Core.Experimental.csproj" />
<PackageReference
Condition="'$(UseExperimentalProjectReference)' != 'true'"
Include="Azure.Core.Experimental" />
</ItemGroup>

<!--
Add any shared properties you want for the projects under this package directory that need to be set before the auto imported Directory.Build.props
-->
Expand Down
23 changes: 4 additions & 19 deletions sdk/search/Azure.Search.Documents/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Use the **Azure.Search.Documents client library** to:
Install the Azure Cognitive Search client library for .NET with [NuGet][nuget]:

```Powershell
dotnet add package Azure.Search.Documents --version 1.0.0-preview.3
dotnet add package Azure.Search.Documents --version 1.0.0-preview.4
```

### Prerequisites
Expand Down Expand Up @@ -112,7 +112,7 @@ AzureKeyCredential credential = new AzureKeyCredential(apiKey);
SearchClient client = new SearchClient(serviceEndpoint, indexName, credential);

// Let's get the top 5 jobs related to Microsoft
SearchResults<SearchDocument> response = client.Search("Microsoft", new SearchOptions { Size = 5 });
SearchResults<SearchDocument> response = client.Search<SearchDocument>("Microsoft", new SearchOptions { Size = 5 });
foreach (SearchResult<SearchDocument> result in response.GetResults())
{
// Print out the title and job description (we'll see below how to
Expand Down Expand Up @@ -190,7 +190,7 @@ AzureKeyCredential credential = new AzureKeyCredential(key);
SearchClient client = new SearchClient(endpoint, indexName, credential);
```

There are three ways to interact with the data returned from a search query.
There are two ways to interact with the data returned from a search query.
Let's explore them with a search for a "luxury" hotel.

#### Use `SearchDocument` like a dictionary
Expand All @@ -199,7 +199,7 @@ Let's explore them with a search for a "luxury" hotel.
provide your own. Here we perform the search, enumerate over the results, and
extract data using `SearchDocument`'s dictionary indexer.
```C# Snippet:Azure_Search_Tests_Samples_Readme_Dict
SearchResults<SearchDocument> response = client.Search("luxury");
SearchResults<SearchDocument> response = client.Search<SearchDocument>("luxury");
foreach (SearchResult<SearchDocument> result in response.GetResults())
{
SearchDocument doc = result.Document;
Expand All @@ -209,21 +209,6 @@ foreach (SearchResult<SearchDocument> result in response.GetResults())
}
```

#### Use `SearchDocument` with [C#'s `dynamic` keyword](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/types/using-type-dynamic)

This starts out the same, but the use of `dynamic` makes the code a little
easier to read.
```C# Snippet:Azure_Search_Tests_Samples_Readme_Dynamic
SearchResults<SearchDocument> response = client.Search("luxury");
foreach (SearchResult<SearchDocument> result in response.GetResults())
{
dynamic doc = result.Document;
string id = doc.hotelId;
string name = doc.hotelName;
Console.WriteLine("{id}: {name}");
}
```

#### Use C# types

We can also decorate our own types with [attributes from `System.Text.Json`](https://docs.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-how-to)
Expand Down
Loading

0 comments on commit e95f06f

Please sign in to comment.