Type definition in a mapping file


(Ajit Shrivastav) #1

If there is a requirement to have a composite structure (hierarchical) in payload, is there a way to define mapping type.

Example payload :-

{
"employee" : {
"firstName" : "Ajit",
"lastName" : "Shrivastav",
"manager" : {
"firstName" : "1stManager fName",
"lastName" : "1stManager lName",
"manager" : {
"firstName" : "2ndManager fName",
"lastName" : "2ndManager lName",
"manager" : null
}
}
}
}

"manager" is of type "person",
Mapping would like :-
{
"person": {
"properties": {
"firstName" : { "type" : "string", "index": "not_analyzed" },
"lastName" : { "type" : "string", "index": "not_analyzed" },
"manager" : {// here need to reuse the "person" type
}
}
}
}

So, the question is - Is there a way to define a type in mapping document and reuse them?

-Ajit


(Magnus B├Ąck) #2

No, that's not possible in the index template format itself. You'd have to use a template or macro processor.


(system) #3