Skip to content

Commit

Permalink
Add Get{Resource}Names methods and remove $select support
Browse files Browse the repository at this point in the history
Fixes Azure#11393. For now, there's very little practical value for passing $select given restrictions in which fields can even be specified (limited) and that they may be cased differently than models (Search is case-sensitive). But the server does have an optimized code path for returning just names, so we expose those methods instead.
  • Loading branch information
heaths committed May 7, 2020
1 parent 466b1d2 commit 013ad73
Show file tree
Hide file tree
Showing 5 changed files with 246 additions and 111 deletions.
39 changes: 0 additions & 39 deletions sdk/search/Azure.Search.Documents/src/Models/SynonymMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Azure.Core;

namespace Azure.Search.Documents.Models
Expand Down Expand Up @@ -67,42 +65,5 @@ public ETag? ETag
get => _etag is null ? (ETag?)null : new ETag(_etag);
set => _etag = value?.ToString();
}

/// <summary>
/// Canonicalizes property names from how they appear on <see cref="SynonymMap"/> to those expected by the Search service.
/// </summary>
/// <param name="names">The given property names.</param>
/// <returns>Canonicalized property names expected by the Search service, or null if <paramref name="names"/> is null.</returns>
internal static IEnumerable<string> CanonicalizePropertyNames(IEnumerable<string> names) =>
// TODO: Replace when https://github.com/Azure/azure-sdk-for-net/issues/11393 is resolved.
names?.Select(name =>
{
if (string.Equals("name", name, StringComparison.InvariantCultureIgnoreCase))
{
return "name";
}

if (string.Equals("format", name, StringComparison.InvariantCultureIgnoreCase))
{
return "format";
}

if (string.Equals("synonyms", name, StringComparison.InvariantCultureIgnoreCase))
{
return "synonyms";
}

if (string.Equals("encryptionKey", name, StringComparison.InvariantCultureIgnoreCase))
{
return "encryptionKey";
}

if (string.Equals("etag", name, StringComparison.InvariantCultureIgnoreCase))
{
return "@odata.etag";
}

return name;
});
}
}
Loading

0 comments on commit 013ad73

Please sign in to comment.