I have a json file which contains hierarchical structure. I want to create multiple nested type mapping for this data. When i do it and try to search a field it gives exception in search query.
Below is the example of json data that I have. I cannot post original data cos its forbidden.
{
"elementType" : {
"type" : "knowledge",
"entity" : [ { "media" : "book"
"subject" : [
{"name" : "maths" ,
"division" : [
{"name" : "linear Algebra"},
{"name" : "calculas"},
{"name" : "sets"}
]},
{"name" : "economics",
"division" : [
{"name" : "macro economics"},
{"name" : "micro economics"}
]}
{ "name" : "biology"}
]},
{ "media" , "DVD"},
{ "media", "usb"}
]
}
}
i was able to create nested mapping for entity . I am not able to create nested mapping for subject
Need help to create nested mapping for elementType.entity.subject,
elementType.entity.subject.division. I have taken too many days looking and trying solutions but everything in vein. Please help. If you have any better suggestion feel free to add it. Please note i cannot change my json hierarchy.
You don’t use the dot notation in the mappings- ‘elementType’ is declared as type nested then you have a ‘properties’ field at the same level to declare the fields it holds eg “entity”.
Before you do - are you sure you need the overhead of nested docs? If the objects only have one property (“name”) there’s no need for a nested doc. See this flowchart
This is the sample json that i have provided that i have provided. My actual json is very huge. this is just a simulation of the original 1. I will require Nested type cos i will query inner json arrays.. I am ready to live with the overhead. Regarding not to use. operator i wasnt able to follow u. can you post me some example from my json.
i want to nest elementType.entity & elementType.entity.subject & elementType.entity.subject.division. This are arrays. any help will be appreciated. if I add entity as nested object and perform nested search on elementType.entity.media = knowledge it works fine . But if i try to add another nested object like elementType.entity.subject the same query used to find media throws exception "reason": [nested] nested object under path elementType.entity is not of nested type"
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.