I can't find how to use the .NET Client for Azure search to add a scoring profile. Yes, I know there's a doc to do it using the REST API Thanks.
Asked
Active
Viewed 440 times
2 Answers
5
The scoring profiles have to be created at the same time as the index:
private async Task CreateIndexAsync<T>(string index) where T : class
{
var definition = new Index()
{
Name = index,
Fields = FieldBuilder.BuildForType<T>(),
ScoringProfiles = new List<ScoringProfile>
{
//your scoring profiles here
}
};
if (!_adminServiceClient.Indexes.Exists(index))
{
await _adminServiceClient.Indexes.CreateAsync(definition);
}
}

Bruce Johnston
- 8,344
- 3
- 32
- 42

Mario Lopez
- 1,405
- 13
- 24
0
If you are using v11
of Azure search library for .Net
you can add scoring profile to the search index like this:
var fieldBuilder = new FieldBuilder();
var searchFields = fieldBuilder.Build(typeof(MyType));
var definition = new SearchIndex(name: "MyIndexName", searchFields);
definition.ScoringProfiles.Add(new ScoringProfile(name: "default")
{
// Your scoring profile definition
}
await _searchIndexClient.CreateIndexAsync(definition);

Ramūnas
- 1,494
- 18
- 37