Nested documents

I'm writing an asset management application. It lets users store arbitrary
asset attributes by adding an html control such as a text field, select
menu, etc. to the asset. A JSON representation of the attribute then
becomes part of the asset JSON document stored in couchdb. An asset has the
following structure in 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
}
]
}

I'm not sure if putting attributes in an array is the best way to allow
searching for an asset based on an attribute value. Would it be better to
attach the attribute directly to the asset as a property? I'm experimenting
now in elasticsearch. If I try and store the document as is, elasticsearch
returns an error:

"error" : "MapperParsingException[Failed to parse [attributes.data]];
nested: ElasticSearchIllegalArgumentException[unknown property [text]]; "

I"m using the following mapping:

{
"settings" : {
"analysis" : {
"analyzer" : {
"str_filtered_search_analyzer" : {
"tokenizer" : "keyword",
"filter" : ["lowercase"]
},
"str_prefix_analyzer" : {
"tokenizer" : "keyword",
"filter" : ["lowercase", "prefix"]
},
"str_substring_analyzer" : {
"tokenizer" : "keyword",
"filter" : ["lowercase", "substring"]
}
},
"filter" : {
"prefix" : {
"type" : "edgeNGram",
"min_gram" : 2,
"max_gram" : 24,
"side": "front"
},
"substring" : {
"type" : "nGram",
"min_gram" : 2,
"max_gram" : 24
}
}
}
},
"mappings" : {
"asset" : {
"properties" : {
"_id": {
"type" : "string",
"index" : "not_analyzed"
},
"_rev": {
"type" : "string",
"index" : "not_analyzed"
},
"type": {
"type" : "string",
"index" : "not_analyzed"
},
"attributes": {
"type" : "nested"
}
}
}
}
}

Any idea what I'm doing wrong here?

Thanks,

Troy

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.