First start ES with /etc/elasticsearch/default-mapping.json
, then index several documents with inner objects
curl -XPOST -d '{"key":{"subkey1":1, "subkey2":1}}' localhost:9200/toto/toto/1
curl -XPOST -d '{"key2":{"subkey1":1, "subkey2":1}}' localhost:9200/toto/toto/2
curl -XPOST -d '{"key3":{"subkey1":1, "subkey2":1}}' localhost:9200/toto/toto/3
Finally, launch the query
$ curl -XPOST -d @query.json localhost:9200/toto/_search
{"took":7,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":1.0,"hits":[{"_index":"toto","_type":"toto","_id":"2","_score":1.0,"_source":{"key2":{"subkey1":1, "subkey2":1}}}]}}
But if there is multiple nested objects then in this case how we can put the mapping file