Upsert into nested field

I'm trying to upsert (push) and object into a nested field.

We have data in xml that comes in like this:

<name>John Smith</name>
<address>123 xyz street</address>
<city>Town A</city>
<StateProvince>State A</StateProvince>
<Country>Country A</Country>
<Address>3456 abc street</address>
<Sity>Town B</city>
<StateProvince>State B</StateProvince>
<Country>Country B</Country>

Expected Output:

  "name": John Smith,
  "age": 34,
  "position": Accounting,
  "addresses": [
        "address": "123 xyz street",
        "city": "Town A",
        "stateProvince": "State A",
        "country": "Country A",
        "postalCode": "85739"
        "address": "3456 abc street",
        "city": "Town B",
        "state": "State B",
        "country": "Country B",
        "postalCode": "12345"

Ruby Script to create addresses object:

ruby {
        code => '
          event.set("addresses", [
              "address" => event.get("[profile][addressinfo][Address]"), 
              "city" => event.get("[profile][addressinfo][City]"),
              "stateProvince" => event.get("[profile][addressinfo][StateProvince]"),
              "country" => event.get("[profile][addressinfo][country]"),
              "postalCode" => event.get("[profile][addressinfo][PostalCode]")

Logstash Output:

elasticsearch {
        hosts => ["localhost:9200"]
        action => "update"
        doc_as_upsert => true
        document_id => "%{id}"     
        index => "sentinel"
        script => 'ctx._source.addresses.add("%{addresses}")'


  "status"=>400, "error"=>{"type"=>"mapper_parsing_exception", "reason"=>"object mapping for [addresses] tried to parse field [null] as object, but found a concrete value"}}}}

bump. still trying to figure this one out

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.