Java partial update

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Java partial update

michalj
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"
  }
}

--
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Java partial update

sowmyak
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 <[hidden email]> wrote:
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\": \"<a href="tel:%2B48123456789" value="+48123456789" target="_blank">+48123456789\",\"model\": \"<a href="tel:%2B48123456789" value="+48123456789" target="_blank">+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"
  }
}

--
 
 

--
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Java partial update

michalj
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
Reply | Threaded
Open this post in threaded view
|

Re: Java partial update

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