JSONオブジェクトとAzure検索インデックスの間のフィールドマッピングをC#でプログラムで定義したいと考えています。私はC#の同等のコードが必要しかし、私はここにJavaScriptでこれを行う方法について説明https://azure.microsoft.com/en-us/documentation/articles/search-howto-index-json-blobs/C#コードでAzureSearchインデックスフィールドマッピングを定義する
"fieldMappings" : [
{ "sourceFieldName" : "/article/text", "targetFieldName" : "text" },
{ "sourceFieldName" : "/article/datePublished", "targetFieldName" : "date" },
{ "sourceFieldName" : "/article/tags", "targetFieldName" : "tags" }
]
を発見しました。
var index = new
{
name = "testindex",
fields = new []
{
//...
},
fieldMappings = new[]
{
new { sourceFieldName = "/status/text", targetFieldName = "text"}
}
}
をしかし、このコードは例外
{"Azure Search request failed:{\"error\":{\"code\":\"\",\"message\":\"The request is invalid. Details: index : The property 'fieldMappings' does not exist on type 'Microsoft.Azure.Search.V2015_02_28.IndexDefinition'. Make sure to only use property names that are defined by the type.\\r\\n\"}}"}
と私はプログラム的にC#コードでこれらのフィールドマッピングを定義する方法上の任意の提案をクラッシュ:私はこれまで試してみましたか?さらに、これらのfieldMappingsをインデックス定義のインデクサ内で定義する必要がありますか?ありがとうございました!
@LaterEdit:この記事の内容Creating Collection in Azure Search Service using Indexerこれらのマッピングはインデクサで定義する必要があることがわかりましたが、インデクサを定義する際にこれらを追加するとfieldMappingsプロパティは存在しません。
var indexer = new
{
name = "textixr",
dataSourceName = "testsdocdb",
schedule = new { interval = "PT5M" }, // every 5 minutes
targetIndexName = "test",
fieldMappings = new []
{
new { sourceFieldName = "/status/text", targetFieldName = "text" }
}
};
ありがとうございました。 2015-02-28 - プレビューでエラーが発生しません。しかし、私はcontainer.queryプロパティでSqlのようなクエリを使用する方法がわかりません。多分私に例を挙げたり、これが言及されている記事を教えてください。 – Crista23
ドキュメントをフラット化するために、SELECT c.id、c._ts、** c.status.text ASテキストのようなデータソースを定義するには、SQLクエリを使用する必要があります。** FROM Collection c WHERE c._ts> = @HighWaterMark 。リンク先の記事には例があります。 –
ありがとうございました!私は現在、DocumentDbデータベース、AzureSearchインデクサとインデクサをC#でプログラム的に作成していますが、C#でこの構文を呼び出す方法はありますか? – Crista23