json 形式のインデックス スキーマを使用して azure で検索インデックスを作成すると問題が発生します。json形式を確認しましたが、すべて問題ありませんでした。しかし、azure search api へのポスト リクエストでは、エラーで応答します。
{"error":{"code":"","message":"The request is invalid.","innererror":{"message":"index : An unexpected 'PrimitiveValue' node was found when reading from the JSON reader. A 'StartObject' node was expected.\r\n","type":"","stacktrace":""}}}
ここに私の作成インデックスコードがあります:
Dim client = New RestClient("https://xxxx.search.windows.net/indexes?api-version=2014-07-31-Preview")
Dim request = New RestRequest(Method.POST)
request.AddHeader("api-key", "asdasdsaD6AxxxxD7B572F17DBAC1")
request.AddJsonBody(File.ReadAllText(Server.MapPath("~/IndexSchema.json")))
Dim response = client.Execute(request)
ここにある IndexSchema.json ファイルの内容
{
"name": "musicstoreindex",
"fields": [
{ "name": "key", "type": "Edm.String", "key": true },
{ "name": "albumTitle", "type": "Edm.String", "suggestions": true },
{ "name": "albumUrl", "type": "Edm.String", "filterable": false },
{ "name": "genre", "type": "Edm.String" },
{ "name": "genreDescription", "type": "Edm.String", "filterable": false },
{ "name": "artistName", "type": "Edm.String", "suggestions": true },
{ "name": "orderableOnline", "type": "Edm.Boolean" },
{ "name": "rating", "type": "Edm.Int32" },
{ "name": "tags", "type": "Collection(Edm.String)" },
{ "name": "price", "type": "Edm.Double", "filterable": false },
{ "name": "margin", "type": "Edm.Int32", "retrievable": false },
{ "name": "inventory", "type": "Edm.Int32" },
{ "name": "lastUpdated", "type": "Edm.DateTimeOffset" }
],
"scoringProfiles": [
{
"name": "boostGenre",
"text": {
"weights": {
"albumTitle": 5,
"genre": 50,
"artistName": 5
}
}
},
{
"name": "newAndHighlyRated",
"functions": [
{
"type": "freshness",
"fieldName": "lastUpdated",
"boost": 10,
"interpolation": "quadratic",
"freshness": {
"boostingDuration": "P365D"
}
},
{
"type": "magnitude",
"fieldName": "rating",
"boost": 10,
"interpolation": "linear",
"magnitude": {
"boostingRangeStart": 1,
"boostingRangeEnd": 5,
"constantBoostBeyondRange": false
}
}
]
},
{
"name": "boostMargin",
"functions": [
{
"type": "magnitude",
"fieldName": "margin",
"boost": 50,
"interpolation": "linear",
"magnitude": {
"boostingRangeStart": 50,
"boostingRangeEnd": 100,
"constantBoostBeyondRange": false
}
}
]
}
]
}