I'm sending data to my elasticsearch index using JestClient in java(using a POJO class).
JSONObject obj1 = new JSONObject();
obj1.put("name","answer");
test1 document = new test1(); //test1 is a POJO class
document.setQAJoinField(obj1);
document.setBody(str);
document.setCreationDate();
document.setOwner("Registration");
document.setIsValid(true);
JestResult result1 = jestClient.execute(new Index.Builder(document).index("idxquesanswer").type("_doc").id(Integer.toString(id)).build());
The above code works well. But,
JSONObject obj2 = new JSONObject();
obj2.put("name","question");
obj2.put("parent",Integer.toString(id-1));
test1 document1 = new test1();
document1.setQAJoinField(obj2);
document1.setBody(str);
document1.setTitle(str);
document1.setIsValid(true);
JestResult result2 = jestClient.execute(new Index.Builder(document1).index("idxquesanswer").type("_doc").id(Integer.toString(id)).build());
In the above code, I get an error:
"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"failed to parse"}],"type":"mapper_parsing_exception","reason":"failed to parse","caused_by":{"type":"illegal_argument_exception","reason":"[routing] is missing for join field [qajoinfield]"}},"status":400}, isSucceeded: false, response code: 400, error message: {"root_cause":[{"type":"mapper_parsing_exception","reason":"failed to parse"}],"type":"mapper_parsing_exception","reason":"failed to parse","caused_by":{"type":"illegal_argument_exception","reason":"[routing] is missing for join field [qajoinfield]"}
How can I resolve it?