Hello.
I use *Elastic Search Java API *for basic *CRUD *operations on ES
documents; with root type documents it is working fine.
However when I want to delete a nested document, I don't know how to use
the Java API and scripting that *Elastic Search *provides.
I have the following root type document which has in it a nested *users property
(nested document).
{
"customer":
{
"_all" : {"enabled" : false},
"_source" : {"enabled" : true},
"store" : "true",
"properties":
{
"location" : { "type": "string", "store": "yes",
"index":"not_analyzed" },
"comments" : { "type": "string", "store": "yes",
"index":"not_analyzed" },
* "users":
-
{*
-
"type":"nested",*
-
"store":"yes", *
-
"properties":*
-
{*
-
"_id" : { "type":"string", "store":"yes",
"index":"not_analyzed" },*
-
"name" : { "type":"string", "store":"yes",
"index":"not_analyzed" },*
-
"birthDate" : { "type":"date", "store":"yes",
"index":"not_analyzed" }*
-
}*
-
}* } }
}
If I want to add a user I do the following in *Java */ *Scala *code:
val json = "
{"_id":"1","name":"Anthony","birthDate":"2013-04-10T06:45:26.186Z"}"
val updateRequest = new UpdateRequest("indexName", "customer", customerId)
updateRequest.script(" if (ctx._source.users == null) { ctx._source.users =
"+json+" } else { ctx._source.users += "+json+" } ")
This works OK for adding nested *users *AKA updating the *customer root type
- document.
How is it to be done for deleting or *updating *a specific user ID from
the nested users nested document?
Thanks!
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.