Hi,
I'm trying to create an index with a parent/child relationship but I'm getting an error while creating the child: "can't specify parent if no parent field has been configured". I don't know how I am supposed to create the mapping between parent and child.
I'm using the 6.0 API.
Code:
// create parent
Map<String, Object> parent = new HashMap<String, Object>();
parent.put("name","Parent1");
parent.put("age", 40);
UUID parentId = UUID.randomUUID();
IndexRequest indexRequest = new IndexRequest(INDEX_JOIN_DATATYPE_TEST, "parent", parentId.toString())
.source(parent);
IndexResponse indexResponse = client.index(indexRequest);
// create children
Map<String, Object> child1 = new HashMap<String, Object>();
child1.put("name","Child1");
child1.put("age", 20);
child1.put("parentId", parentId.toString());
indexRequest = new IndexRequest(INDEX_JOIN_DATATYPE_TEST, "child", UUID.randomUUID().toString())
.source(child1);
indexRequest.parent("parent");
indexResponse = client.index(indexRequest);
Can anyone tell me how to use the api correctly? The documentation is not sufficient for me ...
Greetings