dynamic - How to index parts of jsonObject by setting custom mappings in Elasticsearch? -


i have such jsonobject:

{ "success": true, "type": "message", "body": { "_id": "5215bdd32de81e0c0f000005",     "id": "411c79eb-a725-4ad9-9d82-2db54dfc80ee",     "type": "metamodel",     "title": "testchang",     "authorid": "5215bd552de81e0c0f000001",     "drawelems": [     {         "type": "app.draw.metaelem.modelstartphase",         "id": "27re7e35-550j",         "x": 60,         "y": 50,         "width": 50,         "height": 50,         "title": "problem engagement",         "isghost": true,         "pointto": "e88e2845-37a4-4c45-a030-d02a3c3e03f9",         "bindingid": "90f79d70-0afc-11e3-98d2-83967d2ad9a6",         "model": "meta",         "entitytype": "phase",         "domainid": "411c79eb-a725-4ad9-9d82-2db54dfc80ee",         "authorid": "5215bd552de81e0c0f000001",         "userdata": {},         "_id": "5215f4c5d89f629c1700000d"     },    {...}   ] }} 

i want index parts of object, defined explicit mapping myself , disabled dynamic mapping. here mapping:

string mapping=xcontentfactory.jsonbuilder().startobject(). startobject("domaindata").field("dynamic","false"). startobject("properties") .startobject("success").field("type","string").endobject() .startobject("type").field("type","string").endobject() .startobject("body").field("type", "object") .startobject("properties") .startobject("id").field("type","string").field("store","yes").endobject() .startobject("type").field("type","string").field("store","yes").endobject() .startobject("title").field("type","integer").field("store","yes").endobject() .startobject("drawelems").field("type","nested") .startobject("properties") .startobject("type").field("store","yes").field("type","string").endobject() .startobject("title").field("store","yes").field("type","string").endobject() .endobject().endobject().endobject().endobject().endobject().endobject().endobject().string(); 

i added mapping in index:

node.client().admin()             .indices().preparecreate("testdomaindata")             .addmapping("domaindata", mapping)             .execute().actionget(); 

and indexed following code:

node.client().preparebulk().add(node.client()  .prepareindex("testdomaindata","domaindata",string).setsource(responsedomaindata1))  .execute().actionget(); 

i used getresponse , head plugin check if jsonobject indexed correctly. problem mapping, jsonobject seems not indexed @ all. in head plugin, index , type has been created there no doc in index , type.

did define incorrect mapping? or there mistakes in other codes? give me advices? lot!

here mapping got in index metadata:

{ domaindata:    {     dynamic: false     properties: {         body: {             properties: {                 id: {                     store: true                     type: string                 }                 title: {                     store: true                     type: integer                 }                 drawelems: {                     properties: {                         title: {                             store: true                             type: string                         }                         type: {                             store: true                             type: string                         }                     }                     type: nested                 }                 type: {                     store: true                     type: string                 }             }         }         type: {             type: string         }         success: {             type: string         }     } }  } 

if read mapping correctly, index wait integer title field, , give string. thus, indexation fail.

here's hoping simple. luck


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -