New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parent is not getting set, using UpdateRequest in JavaAPI #4538
Comments
The UpdateRequest#parent() method should only be used to set routing if not set already via the routing setter, it doesn't set the _parent field (see the java doc). You should set the |
Thanks @martijnvg, that works 👍 but, when docAsUpsert as true & it can create new document than it should set _parent mapping field. It seems little confusing to me as parent() method in update action has different behaviour than other actions. |
In the update request, the parent method's purpose if for routing only. I think it should be removed, to avoid confusion. |
I misunderstood what had to be done for this issue. The The issue here is that although in normal use case the parent option is ignore and just a place holder for routing, in the case a document doesn't exist the parent option should be delegated to the upsert document. I'll do the following changes:
|
Any timeline as to when this might get resolved? After spending a morning trying to figure out why my This has left me a bit scuppered. Any suggestions for a workaround would also be appreciated. |
Thanks, I've copied in the changes to I believe I found an issue with the changes though, and have added a comment: https://github.com/elasticsearch/elasticsearch/pull/9612/files#r25503572 |
…ed to upsert index request. Closes elastic#4538
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
The text was updated successfully, but these errors were encountered: