Java partial update


(michalj) #1

Hi.
I'm having some problems with partial update of documents with java api.
When I'm using post calls documents are updated correctly.
This how it looks in java:

    String id = "1";
    UpdateRequestBuilder updater = getClientToElasticSearch().prepareUpdate("test_idx", "subscriber", id);
    String script = "{\"script\":\"ctx._source.device = device\", \"params\":{\"device\":{\"brand\": \"+48123456789\",\"model\": \"+48123456789\"}}}";
    updater.setScript(script);
    updater.execute().actionGet();

There is no error message on this query, but data is not updated.

What's wrong with script above?

BR

I'm using ES in 0.19.8.My data:{ "device":{ "brand": "Brand 1", "model": "bRAND 2" }, "personal": { "login": "login", "firstName": "first name", "lastName": "last name", "address": "address", "zipCode": "zip code", "city": "city", "country": "COUNTRY", "language": "LanGuage" }}

--


(sowmyak) #2

Hi,

Each element should be seperated with a semicolon, but not with a comma.

On Tue, Aug 28, 2012 at 9:36 AM, misiek jendryszka oniron9th@hotmail.comwrote:

Hi.
I'm having some problems with partial update of documents with java api.
When I'm using post calls documents are updated correctly.
This how it looks in java:

    String id = "1";
    UpdateRequestBuilder updater =

getClientToElasticSearch().prepareUpdate("test_idx", "subscriber", id);
String script = "{"script":"ctx._source.device = device",
"params":{"device":{"brand": "+48123456789","model": "
+48123456789"}}}";
updater.setScript(script);
updater.execute().actionGet();

There is no error message on this query, but data is not updated.

What's wrong with script above?

BR

I'm using ES in 0.19.8.
My data:
{
"device":{
"brand": "Brand 1",
"model": "bRAND 2"
},
"personal": {
"login": "login",
"firstName": "first name",
"lastName": "last name",
"address": "address",
"zipCode": "zip code",
"city": "city",
"country": "COUNTRY",
"language": "LanGuage"
}
}

--

--


(michalj) #3

I'm not sure if I get You.
After suggested change the script looks like:
String script = "{"script":"ctx._source.device = device"; "params":{"device":{"brand": "+48123456789"; "model": "+48123456789"}}}";
And still does not work.
BR


(michalj) #4

Nut this seems to work:
String script = "ctx._source.device.brand = "deice";ctx._source.device.model = "model"";
Thnx
BR


(system) #5