Defines one mapping type for a set of of subfields

Hello,

Is there a way to define a type for a set of sub fields ? Let say I have:
myfield.mysubfield1
myfield.mysubfield2

Is it possible to define the mapping like that :

  "myfield": {
    "type": "float",
  },

So as mysubfield1 and mysubfield2 will be of type float without having to define all of them in the mapping ?

Thanks

You can do something like this with dynamic templates : https://www.elastic.co/guide/en/elasticsearch/reference/6.1/dynamic-templates.html

Thanks @dadoonet for the answer, from this dynamic template how could I map an array of repeated set of fields of same type ? and without the same type (not sure it's possible from the documentation) ? :

Example :
"field":{"subfield1":[{"subsubfield1":"1","subsubfield2":"246","subsubfield3":"6538","subsubfield4":"-84","subsubfield5":"102"},{"subsubfield1":"1","subsubfield2":"246","subsubfield3":"6540","subsubfield4":"-92","subsubfield5":"102"}]

Please format your code using </> icon as explained in this guide and not the citation button. It will make your post more readable.

Or use markdown style like:

```
CODE
```

Please edit your post.

In the example you posted, what are the expected settings/mappings you would like to have?

Sorry, post updated. I think the output would looks like a concatenation of the values for each identical subfields :

field.subfield1.subsubfield1=[1, 1]
field.subfield1.subsubfield2=[246, 246]
field.subfield1.subsubfield3=[6538, 6540]
field.subfield1.subsubfield4=[-84, -92]
field.subfield1.subsubfield5=[102, 102]

I don't see why dynamic template would not work in that case.
Did you try?

I tried, but in fact I mixed some stuff and when checking again there is no error for parsing this kind of data except that it leave them as a json displayed in Kibana with a warning saying that "Objects in array are not well supported" :

 {
  "subsubfield1": "131",
  "subsubfield2": "246",
  "subsubfield3": "1",
  "subsubfield4": "9226",
  "subsubfield5": "-75"
},
{
  "subsubfield1": "171",
  "subsubfield2": "246",
  "subsubfield3": "10",
  "subsubfield4": "9227",
  "subsubfield5": "-83"
},
{
  "subsubfield1": "134",
  "subsubfield2": "245",
  "subsubfield3": "3",
  "subsubfield4": "9420",
  "subsubfield5": "-91"
},
{
  "subsubfield1": "121",
  "subsubfield2": "249",
  "subsubfield3": "1",
  "subsubfield4": "9404",
  "subsubfield5": "-95"
}

Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.