---
setup:
 - do:
      indices.create:
          index: test_1
          body:
            mappings:
              test:
                _parent: { type: "foo" }
---
"Parent":

 - do:
      catch:      /routing_missing_exception/
      update:
          index:   test_1
          type:    test
          id:      1
          body:
            doc:        { foo: baz }
            upsert:     { foo: bar }

 - do:
      update:
          index:   test_1
          type:    test
          id:      1
          parent:  5
          body:
            doc:        { foo: baz }
            upsert:     { foo: bar }

 - do:
      get:
          index:   test_1
          type:    test
          id:      1
          parent:  5
          stored_fields:  [_parent, _routing]

 - match: { _parent:  "5"}
 - match: { _routing: "5"}

 - do:
      update:
          index:   test_1
          type:    test
          id:      1
          parent:  5
          _source:  foo
          body:
            doc:        { foo: baz }

 - match: { get._source.foo: baz }

---
"Parent omitted":

 - do:
      index:
          index:   test_1
          type:    test
          id:      1
          parent:  5
          body:    { foo: bar }

 - do:
      catch:      bad_request
      update:
          index:   test_1
          type:    test
          id:      1
          body:
            doc:        { foo: baz }

