I wasn't entirely clear -- the object is inside the document, so it's {"obj": {"a": 1, "b": 2}}
Removing the property doesn't seem to be enough. Here's an example (I'm using the bulk API, but it should work the same as the regular API):
$ curl -XPUT -H 'content-type: application/json' -d $'
{
"mappings": {
"properties": {
"obj": {
"type": "object",
"dynamic": true
}
}
}
}' localhost:9200/foo
{"acknowledged":true,"shards_acknowledged":true,"index":"foo"}
$ curl -XPOST -H 'content-type: application/json' -d '{"obj": {"a": 1, "b": 2}}' localhost:9200/foo/_doc/1
{"_index":"foo","_type":"_doc","_id":"1","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":0,"_primary_term":1}
$ curl -XPOST -H 'content-type: application/x-ndjson' -d $'
quote> { "update": { "_id": "1", "_index": "foo" } }
quote> { "doc": { "obj": { "a": 3 } } }
quote> ' localhost:9200/foo/_bulk
{"took":9,"errors":false,"items":[{"update":{"_index":"foo","_type":"_doc","_id":"1","_version":2,"result":"updated","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":1,"_primary_term":1,"status":200}}]}
$ curl localhost:9200/foo/_doc/1\?pretty
{
"_index" : "foo",
"_type" : "_doc",
"_id" : "1",
"_version" : 2,
"_seq_no" : 1,
"_primary_term" : 1,
"found" : true,
"_source" : {
"obj" : {
"a" : 3,
"b" : 2
}
}
}
I forgot to mention I'm on ES 7.13.0.