資産管理アプリケーションを書いています。これにより、ユーザーは、テキストフィールド、選択メニューなどのhtmlコントロールをアセットに追加することにより、任意のアセット属性を保存できます。属性のJSON表現は、couchdbに格納されているアセットJSONドキュメントの一部になります。アセットのcouchdbの構造は次のとおりです。
{
"_id": "9399fb27448b1e5dfdca0181620418d4",
"_rev": "12-fa50eae8b50f745f9852e9fab30ef5d9",
"type": "asset",
"attributes": [
{
"id": "9399fb27448b1e5dfdca01816203d609",
"type": "text",
"heading": "Brand",
"data": "",
"requiredBySystem": true
},
{
"id": "9399fb27448b1e5dfdca01816203e68e",
"type": "userSelectMenu",
"heading": "Assigned To",
"data": "",
"requiredBySystem": true
},
{
"id": "9399fb27448b1e5dfdca01816203e9c9",
"type": "categories",
"heading": "Categories",
"data": [
"0d7e6233e5f48b4f55c5376bf00b1be5",
"0d7e6233e5f48b4f55c5376bf00d94cf"
],
"requiredBySystem": true
},
{
"id": "9399fb27448b1e5dfdca01816207uy5a",
"type": "radio",
"heading": "Radio Buttons",
"data": [
{
"text": "Button 1",
"checked": false
},
{
"text": "Button 2",
"checked": true
}
],
"requiredBySystem": true
},
{
"id": "9399fb27448b1e5dfdca01816205tgh6",
"type": "checkboxes",
"heading": "Checkboxes",
"data": [
{
"text": "Box 1",
"checked": false
},
{
"text": "Box 2",
"checked": true
}
],
"requiredBySystem": true
},
{
"id": "9399fb27448b1e5dfdca0181620k81gt",
"type": "select",
"heading": "Select Menu",
"data": [
{
"text": "Option 1",
"checked": false
},
{
"text": "Option 2",
"checked": true
}
],
"requiredBySystem": true
}
]
}
属性を配列に配置することが、属性値に基づいてアセットを検索できるようにするための最良の方法であるかどうかはわかりません。属性をプロパティとしてアセットに直接アタッチする方がよいでしょうか?私は現在elasticsearchで実験しています。ドキュメントをそのまま保存しようとすると、elasticsearchはエラーを返します。
"エラー": "MapperParsingException [[attributes.data]]の解析に失敗しました;ネスト:ElasticSearchIllegalArgumentException[不明なプロパティ[テキスト]];"
私は次のマッピングを使用しています:
"mappings" : {
"asset" : {
"properties" : {
"_id": {
"type" : "string",
"index" : "not_analyzed"
},
"_rev": {
"type" : "string",
"index" : "not_analyzed"
},
"type": {
"type" : "string",
"index" : "not_analyzed"
},
"attributes": {
"properties" : {
"id" : {
"type" : "string"
},
"type" : {
"type" : "string",
"index" : "not_analyzed"
},
"heading" : {
"type" : "string"
},
"data" : {
"type" : "string"
}
}
}
}
}
}
ここでどこが間違っているのかわかりません。ご協力いただきありがとうございます!
トロイ