Skip to content

Commit 19abfc9

Browse files
authored
Attribute ScoringProfile.FunctionAggregation as nullable (Azure#16585)
* Attribute ScoringProfile.FunctionAggregation as nullable May resolve Azure#16570, but the issue described didn't repro. That said, based on the response from the service, the field should've been attributed as nullable. * Resolve PR feedback
1 parent 6975fb7 commit 19abfc9

File tree

6 files changed

+395
-4
lines changed

6 files changed

+395
-4
lines changed

sdk/search/Azure.Search.Documents/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Fixed
66

77
- Fixed issue calling `SearchIndexClient.GetIndexNames` that threw an exception ([#15590](https://github.com/Azure/azure-sdk-for-net/issues/15590))
8+
- Fixed issue where `ScoringProfile.FunctionAggregation` did not correctly handle null values ([#16570](https://github.com/Azure/azure-sdk-for-net/issues/16570))
89

910
### Added
1011

sdk/search/Azure.Search.Documents/src/Generated/Models/ScoringProfile.Serialization.cs

Lines changed: 11 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/search/Azure.Search.Documents/src/autorest.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ directive:
104104
where: $.definitions.ScoringProfile
105105
transform: >
106106
$.properties.text["x-nullable"] = true;
107+
$.properties.functionAggregation["x-nullable"] = true;
107108
```
108109
109110
``` yaml

sdk/search/Azure.Search.Documents/tests/SearchIndexClientTests.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,5 +444,47 @@ public async Task AnalyzeText()
444444

445445
Assert.AreEqual(new[] { "The", "quick", "brown", "fox", "jumped", "over", "the", "lazy", "dog." }, tokens.Select(t => t.Token));
446446
}
447+
448+
[Test]
449+
public async Task SetScoringProfile()
450+
{
451+
// Testing: https://github.com/Azure/azure-sdk-for-net/issues/16570
452+
453+
SaveDebugRecordingsOnFailure = true;
454+
455+
await using SearchResources resources = SearchResources.CreateWithNoIndexes(this);
456+
457+
string indexName = Recording.Random.GetName();
458+
string scoringProfileName = Recording.Random.GetName();
459+
460+
// Make sure the index, if created, is cleaned up.
461+
resources.IndexName = indexName;
462+
463+
SearchIndex index = new SearchIndex(indexName)
464+
{
465+
Fields =
466+
{
467+
new SimpleField("id", SearchFieldDataType.String) { IsKey = true },
468+
new SearchableField("title") { IsFilterable = true, IsSortable = false },
469+
},
470+
DefaultScoringProfile = scoringProfileName,
471+
ScoringProfiles =
472+
{
473+
new ScoringProfile(scoringProfileName)
474+
{
475+
TextWeights = new TextWeights(new Dictionary<string, double>
476+
{
477+
{ "title", 2 },
478+
}),
479+
},
480+
},
481+
};
482+
483+
SearchIndexClient client = resources.GetIndexClient();
484+
SearchIndex createdIndex = await client.CreateIndexAsync(index);
485+
486+
Assert.AreEqual(1, createdIndex.ScoringProfiles.Count);
487+
Assert.AreEqual(scoringProfileName, createdIndex.ScoringProfiles[0].Name);
488+
}
447489
}
448490
}

sdk/search/Azure.Search.Documents/tests/SessionRecords/SearchIndexClientTests/SetScoringProfile.json

Lines changed: 170 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)