Last active
August 2, 2023 23:00
-
-
Save beachside-project/991ce8a2f967e4439d153fd38acfb589 to your computer and use it in GitHub Desktop.
Cognitive Search - Camel case sample for System.Text.Json dependency
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// こんな定義があるとして | |
// TODO: Cognitive Search の Uri をセット | |
private static readonly Uri SearchEndpoint = new Uri(""); | |
// TODO: ADMIN の API キーをセット | |
private const string AdminApiKey = ""; | |
// TODO: インデックス名をセット | |
private const string IndexName = ""; | |
// using statement | |
using Azure; | |
using Azure.Core.Serialization; | |
using Azure.Search.Documents; | |
using Azure.Search.Documents.Indexes; | |
using System.Text.Json; | |
// searchClient の生成方法はこれ | |
var jsonSerializerOptions = new JsonSerializerOptions | |
{ | |
PropertyNamingPolicy = JsonNamingPolicy.CamelCase | |
}; | |
var searchClientOptions = new SearchClientOptions {Serializer = new JsonObjectSerializer(jsonSerializerOptions)}; | |
var credential = new AzureKeyCredential(AdminApiKey); | |
var searchClient = new SearchClient(SearchEndpoint, IndexName, credential, searchClientOptions); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment