Skip to content
Merged
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
7 changes: 0 additions & 7 deletions sdk/search/Azure.Search.Documents/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,10 @@
<UseAzureCoreExperimentalSpatial Condition="'$(UseAzureCoreExperimentalSpatial)' == ''">$(UseAzureCoreExperimental)</UseAzureCoreExperimentalSpatial>
<DefineConstants Condition="'$(UseAzureCoreExperimentalSpatial)' == 'true'">EXPERIMENTAL_SPATIAL;$(DefineConstants)</DefineConstants>

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

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

<UseFieldBuilder Condition="'$(UseFieldBuilder)' == '' AND '$(UseAzureCoreSerializer)' == 'true'">true</UseFieldBuilder>
<DefineConstants Condition="'$(UseFieldBuilder)' == 'true'">EXPERIMENTAL_FIELDBUILDER;$(DefineConstants)</DefineConstants>

<!-- Use a Package or Project reference to Azure.Core.Experimental -->
<AddExperimentalReference Condition="('$(UseAzureCoreExperimentalSpatial)' == 'true') OR ('$(UseAzureCoreExperimentalDynamic)' == 'true')">true</AddExperimentalReference>
<UseExperimentalProjectReference Condition="'$(UseExperimentalProjectReference)' == ''">$(UseProjectReferenceToAzureClients)</UseExperimentalProjectReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@
<NoWarn>$(NoWarn);AZC0007;AZC0004;AZC0001</NoWarn>
</PropertyGroup>

<!-- Conditionally compile FieldBuilder and related source -->
<ItemGroup Condition="'$(UseFieldBuilder)' != 'true'">
<Compile Remove="Indexes\FieldBuilder.cs" />
<Compile Remove="Indexes\FieldBuilderIgnoreAttribute.cs" />
<Compile Remove="Indexes\ISearchFieldAttribute.cs" />
<Compile Remove="Indexes\SearchableFieldAttribute.cs" />
<Compile Remove="Indexes\SimpleFieldAttribute.cs" />
</ItemGroup>

<!-- Pull in Shared Source from Azure.Core -->
<ItemGroup>
<Compile Include="$(AzureCoreSharedSources)Argument.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
Expand Down
2 changes: 0 additions & 2 deletions sdk/search/Azure.Search.Documents/src/Indexes/FieldBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
using System.Linq;
using System.Reflection;
using Azure.Core;
#if EXPERIMENTAL_SERIALIZER
using Azure.Core.Serialization;
#endif
using Azure.Search.Documents.Indexes.Models;
#if EXPERIMENTAL_SPATIAL
using Azure.Core.Spatial;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ namespace Azure.Search.Documents.Indexes.Models
{
public readonly partial struct LexicalAnalyzerName
{
#if EXPERIMENTAL_FIELDBUILDER
#pragma warning disable CA1034 // Nested types should not be visible
/// <summary>
/// The values of all declared <see cref="LexicalAnalyzerName"/> properties as string constants.
Expand Down Expand Up @@ -201,6 +200,5 @@ public static class Values
public const string Whitespace = LexicalAnalyzerName.WhitespaceValue;
}
#pragma warning restore CA1034 // Nested types should not be visible
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public SearchIndex(string name, IEnumerable<SearchField> fields)
/// </summary>
public IList<CharFilter> CharFilters { get; }

#if EXPERIMENTAL_FIELDBUILDER
/// <summary>
/// Gets or sets the fields in the index.
/// Use <see cref="FieldBuilder"/> to define fields based on a model class,
Expand Down Expand Up @@ -126,44 +125,6 @@ public SearchIndex(string name, IEnumerable<SearchField> fields)
/// };
/// </code>
/// </example>
#else
/// <summary>
/// Gets or sets the fields in the index.
/// Use <see cref="SimpleField"/>, <see cref="SearchableField"/>, and <see cref="ComplexField"/> to manually define fields.
/// Index fields have many constraints that are not validated with <see cref="SearchField"/> until the index is created on the server.
/// </summary>
/// <example>
/// You can create fields manually using helper classes:
/// <code snippet="Snippet:Azure_Search_Tests_Samples_Readme_CreateManualIndex_New_SearchIndex">
/// SearchIndex index = new SearchIndex(&quot;hotels&quot;)
/// {
/// Fields =
/// {
/// new SimpleField(&quot;hotelId&quot;, SearchFieldDataType.String) { IsKey = true, IsFilterable = true, IsSortable = true },
/// new SearchableField(&quot;hotelName&quot;) { IsFilterable = true, IsSortable = true },
/// new SearchableField(&quot;description&quot;) { AnalyzerName = LexicalAnalyzerName.EnLucene },
/// new SearchableField(&quot;tags&quot;, collection: true) { IsFilterable = true, IsFacetable = true },
/// new ComplexField(&quot;address&quot;)
/// {
/// Fields =
/// {
/// new SearchableField(&quot;streetAddress&quot;),
/// new SearchableField(&quot;city&quot;) { IsFilterable = true, IsSortable = true, IsFacetable = true },
/// new SearchableField(&quot;stateProvince&quot;) { IsFilterable = true, IsSortable = true, IsFacetable = true },
/// new SearchableField(&quot;country&quot;) { IsFilterable = true, IsSortable = true, IsFacetable = true },
/// new SearchableField(&quot;postalCode&quot;) { IsFilterable = true, IsSortable = true, IsFacetable = true }
/// }
/// }
/// },
/// Suggesters =
/// {
/// // Suggest query terms from the hotelName field.
/// new SearchSuggester(&quot;sg&quot;, &quot;hotelName&quot;)
/// }
/// };
/// </code>
/// </example>
#endif
public IList<SearchField> Fields
{
get => _fields;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
using System.Threading.Tasks;
using Azure.Core;
using Azure.Core.Pipeline;
#if EXPERIMENTAL_SERIALIZER
using Azure.Core.Serialization;
#endif
using Azure.Search.Documents.Indexes.Models;

namespace Azure.Search.Documents.Indexes
Expand All @@ -23,9 +21,7 @@ public class SearchIndexClient
private readonly HttpPipeline _pipeline;
private readonly ClientDiagnostics _clientDiagnostics;
private readonly SearchClientOptions.ServiceVersion _version;
#if EXPERIMENTAL_SERIALIZER
private readonly ObjectSerializer _serializer;
#endif

private ServiceRestClient _serviceClient;
private IndexesRestClient _indexesClient;
Expand Down Expand Up @@ -76,9 +72,7 @@ public SearchIndexClient(

options ??= new SearchClientOptions();
Endpoint = endpoint;
#if EXPERIMENTAL_SERIALIZER
_serializer = options.Serializer;
#endif
_clientDiagnostics = new ClientDiagnostics(options);
_pipeline = options.Build(credential);
_version = options.Version;
Expand Down Expand Up @@ -146,9 +140,7 @@ public virtual SearchClient GetSearchClient(string indexName)
return new SearchClient(
Endpoint,
indexName,
#if EXPERIMENTAL_SERIALIZER
_serializer,
#endif
_pipeline,
_clientDiagnostics,
_version);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
using System.Threading;
using System.Threading.Tasks;
using Azure.Core;
#if EXPERIMENTAL_SERIALIZER
using Azure.Core.Serialization;
#endif

#pragma warning disable SA1402 // File may only contain a single type

Expand Down Expand Up @@ -79,9 +77,7 @@ public IndexDocumentsAction(IndexActionType type, T doc)
/// <returns>A task representing the serialization.</returns>
internal async Task SerializeAsync(
Utf8JsonWriter writer,
#if EXPERIMENTAL_SERIALIZER
ObjectSerializer serializer,
#endif
JsonSerializerOptions options,
bool async,
CancellationToken cancellationToken)
Expand All @@ -97,7 +93,6 @@ internal async Task SerializeAsync(
// HACK: Serialize the user's model, parse it, and then write each
// of its properties as if they were our own.
byte[] json;
#if EXPERIMENTAL_SERIALIZER
if (serializer != null)
{
using MemoryStream stream = new MemoryStream();
Expand All @@ -113,11 +108,8 @@ internal async Task SerializeAsync(
}
else
{
#endif
json = JsonSerializer.SerializeToUtf8Bytes<T>(Document, options);
#if EXPERIMENTAL_SERIALIZER
}
#endif
using JsonDocument nested = JsonDocument.Parse(json);
foreach (JsonProperty property in nested.RootElement.EnumerateObject())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
using System.Threading;
using System.Threading.Tasks;
using Azure.Core;
#if EXPERIMENTAL_SERIALIZER
using Azure.Core.Serialization;
#endif

#pragma warning disable SA1402 // File may only contain a single type

Expand Down Expand Up @@ -77,9 +75,7 @@ internal IndexDocumentsBatch(IndexActionType type, IEnumerable<T> documents)
/// <returns>A task representing the serialization.</returns>
internal async Task SerializeAsync(
Utf8JsonWriter writer,
#if EXPERIMENTAL_SERIALIZER
ObjectSerializer serializer,
#endif
JsonSerializerOptions options,
bool async,
CancellationToken cancellationToken)
Expand All @@ -93,9 +89,7 @@ internal async Task SerializeAsync(
{
await action.SerializeAsync(
writer,
#if EXPERIMENTAL_SERIALIZER
serializer,
#endif
options,
async,
cancellationToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
using System.Threading.Tasks;
using Azure.Core;
using Azure.Core.Pipeline;
#if EXPERIMENTAL_SERIALIZER
using Azure.Core.Serialization;
#endif

#pragma warning disable SA1402 // File may only contain a single type

Expand Down Expand Up @@ -167,9 +165,7 @@ await _pagingClient.SearchAsync<T>(
/// <returns>Deserialized SearchResults.</returns>
internal static async Task<SearchResults<T>> DeserializeAsync(
Stream json,
#if EXPERIMENTAL_SERIALIZER
ObjectSerializer serializer,
#endif
bool async,
CancellationToken cancellationToken)
#pragma warning restore CS1572
Expand Down Expand Up @@ -240,9 +236,7 @@ await JsonDocument.ParseAsync(json, cancellationToken: cancellationToken).Config
{
SearchResult<T> result = await SearchResult<T>.DeserializeAsync(
element,
#if EXPERIMENTAL_SERIALIZER
serializer,
#endif
defaultSerializerOptions,
async,
cancellationToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
using System.Threading;
using System.Threading.Tasks;
using Azure.Core;
#if EXPERIMENTAL_SERIALIZER
using Azure.Core.Serialization;
#endif

#pragma warning disable SA1402 // File may only contain a single type

Expand Down Expand Up @@ -70,9 +68,7 @@ internal SearchResult() { }
/// <returns>Deserialized SearchResults.</returns>
internal static async Task<SearchResult<T>> DeserializeAsync(
JsonElement element,
#if EXPERIMENTAL_SERIALIZER
ObjectSerializer serializer,
#endif
JsonSerializerOptions options,
bool async,
CancellationToken cancellationToken)
Expand Down Expand Up @@ -104,7 +100,6 @@ internal static async Task<SearchResult<T>> DeserializeAsync(
}

// Deserialize the model
#if EXPERIMENTAL_SERIALIZER
if (serializer != null)
{
using Stream stream = element.ToStream();
Expand All @@ -115,7 +110,6 @@ internal static async Task<SearchResult<T>> DeserializeAsync(
}
else
{
#endif
T document;
if (async)
{
Expand All @@ -127,9 +121,7 @@ internal static async Task<SearchResult<T>> DeserializeAsync(
document = JsonSerializer.Deserialize<T>(element.GetRawText(), options);
}
result.Document = document;
#if EXPERIMENTAL_SERIALIZER
}
#endif

return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
using System.Threading;
using System.Threading.Tasks;
using Azure.Core;
#if EXPERIMENTAL_SERIALIZER
using Azure.Core.Serialization;
#endif

#pragma warning disable SA1402 // File may only contain a single type

Expand Down Expand Up @@ -62,9 +60,7 @@ internal SearchSuggestion() { }
/// <returns>Deserialized SearchSuggestion.</returns>
internal static async Task<SearchSuggestion<T>> DeserializeAsync(
JsonElement element,
#if EXPERIMENTAL_SERIALIZER
ObjectSerializer serializer,
#endif
JsonSerializerOptions options,
bool async,
CancellationToken cancellationToken)
Expand All @@ -83,7 +79,6 @@ internal static async Task<SearchSuggestion<T>> DeserializeAsync(
}

// Deserialize the model
#if EXPERIMENTAL_SERIALIZER
if (serializer != null)
{
using Stream stream = element.ToStream();
Expand All @@ -94,7 +89,6 @@ internal static async Task<SearchSuggestion<T>> DeserializeAsync(
}
else
{
#endif
T document;
if (async)
{
Expand All @@ -106,9 +100,7 @@ internal static async Task<SearchSuggestion<T>> DeserializeAsync(
document = JsonSerializer.Deserialize<T>(element.GetRawText(), options);
}
suggestion.Document = document;
#if EXPERIMENTAL_SERIALIZER
}
#endif

return suggestion;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
using System.Threading;
using System.Threading.Tasks;
using Azure.Core;
#if EXPERIMENTAL_SERIALIZER
using Azure.Core.Serialization;
#endif

#pragma warning disable SA1402 // File may only contain a single type

Expand Down Expand Up @@ -62,9 +60,7 @@ internal SuggestResults() { }
/// <returns>Deserialized SuggestResults.</returns>
internal static async Task<SuggestResults<T>> DeserializeAsync(
Stream json,
#if EXPERIMENTAL_SERIALIZER
ObjectSerializer serializer,
#endif
bool async,
CancellationToken cancellationToken)
#pragma warning restore CS1572
Expand All @@ -91,9 +87,7 @@ await JsonDocument.ParseAsync(json, cancellationToken: cancellationToken).Config
{
SearchSuggestion<T> suggestion = await SearchSuggestion<T>.DeserializeAsync(
element,
#if EXPERIMENTAL_SERIALIZER
serializer,
#endif
defaultSerializerOptions,
async,
cancellationToken)
Expand Down
Loading