Help with indexing nested json object


(Michael Washaya) #1

how to i index this json object, please help.

[
{
"id":1,
"firstName":"John",
"lastName":"Smith",
"sex":"FEMALE",
"birthdate":1444025680962,
"address":[{"id":1,"streetName":"100 Nzou Street","surbub":"Mufakose","town":"Harare"}],
"identification":[{"id":2,"identificationType":"NATIONAL_ID","value":"42-155800W42"}],
"contactDetails":[{"contactType":"EMAIL","value":"example@test.com"},{"contactType":"CELLPHONE_NUMBER","value": "0774100300"}],
"nextOfKins":[
{
"kinId":2,
"relationshipType":{"name":"Mother","id":1},
"member":{
"id":0,
"firstName":"Ann",
"lastName":"Matemba",
"sex":"MALE",
"birthdate":1444025680964,
"address":[{
"id":1,
"streetName":"100 Nzou Street",
"surbub":"Mufakose",
"town":"Harare"}],
"identification":[{"id":3,"identificationType":"PASSPORT","value":"EN89765"}],
"contactDetails":[{
"contactType":"EMAIL",
"value":"example@test.com"},
{"contactType":"CELLPHONE_NUMBER","value":"0774100300"}],
"nextOfKins":null,
"birthdateOption":"ACTUAL"}}],
"birthdateOption":"ACTUAL"},{"id":4,"firstName":"Mirraim","lastName":"Mwashita","sex":"FEMALE","birthdate":1012255200000,"address":null,"identification":null,"contactDetails":null,"nextOfKins":null,"birthdateOption":"ACTUAL"},{"id":5,"firstName":"Vincent","lastName":"Sox","sex":"MALE","birthdate":134604000000,"address":null,"identification":null,"contactDetails":null,"nextOfKins":null,"birthdateOption":"ACTUAL"},{"id":6,"firstName":"Mawoko","lastName":"Mawoko","sex":"MALE","birthdate":null,"address":null,"identification":null,"contactDetails":null,"nextOfKins":null,"birthdateOption":"ESTIMATE"},{"id":7,"firstName":"Goerge","lastName":"Kondo","sex":"MALE","birthdate":1443391200000,"address":null,"identification":null,"contactDetails":null,"nextOfKins":null,"birthdateOption":null}]


(Magnus B├Ąck) #2

Could you explain what you mean by "how do I index"? Elasticsearch should accept pretty much any valid JSON document. What problem are you having?


(David Pilato) #3

The only issue I see here is that it is enclosed by [].
May be he wants to index individual sub records?

You can may be do something like:

{
  "mystuff": [ // YOUR EXAMPLE HERE ]
}

But as said @magnusbaeck it's hard to understand what you want.


(Michael Washaya) #4

im not well versed with elasticsearch, please bear with me, im using sense and when i use the PUT /people/person/100 together with the valid json, it asks for Expected one of POST or GET though if i execute it indexes, then when i retreive it i get a bad string error along with the object, am i doing something wrong.


(system) #5