Skip to content

Parent is not getting set, using UpdateRequest in JavaAPI #4538

@sandy6jain

Description

@sandy6jain

I found a similar bug #3444, but it is not fixed in JavaAPI with requesting using UpdateReuest.
To resolve this, "UpdateRequest.java" should have property "parent" & it should be used while generating upsertRequest. (I am using version 0.90.5)
Test with the following code :

curl -XPOST 'http://localhost:9200/123'
curl -XPOST 'http://localhost:9200/123/TableWithParent/_mapping' -d '
{"TableWithParent" : {"_parent" : { "type" : "Table1" }}}'

Inserting data using JavaAPI:

public static void main(String[] args) {
Client client = NodeBuilder.nodeBuilder().node().client();
Map<String, Object> data = new HashMap<String, Object>();
data.put("column1", "colVal1");
UpdateRequest updateRequest = new UpdateRequest();
updateRequest.index("123");
updateRequest.docAsUpsert(true);
updateRequest.routing("123");
updateRequest.parent("parentID");
updateRequest.id("123|8|627110220645727|662022187154530");
updateRequest.type("TableWithParent");
updateRequest.doc(data);
client.update(updateRequest);
}

Below query, should return parent object:
curl -XGET 'http://localhost:9200/123/TableWithParent/123|8|627110220645727|662022187154530?routing=123&pretty&fields=_parent,_source'

Thanks

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions