@@ -276,49 +276,59 @@ public void testSearchWithMatrixStats() throws IOException {
276276 }
277277
278278 public void testSearchWithParentJoin () throws IOException {
279+ final String indexName = "child_example" ;
279280 StringEntity parentMapping = new StringEntity ("{\n " +
280281 " \" mappings\" : {\n " +
281- " \" answer\" : {\n " +
282- " \" _parent\" : {\n " +
283- " \" type\" : \" question\" \n " +
282+ " \" qa\" : {\n " +
283+ " \" properties\" : {\n " +
284+ " \" qa_join_field\" : {\n " +
285+ " \" type\" : \" join\" ,\n " +
286+ " \" relations\" : { \" question\" : \" answer\" }\n " +
287+ " }\n " +
284288 " }\n " +
285289 " }\n " +
286- " },\n " +
287- " \" settings\" : {\n " +
288- " \" index.mapping.single_type\" : false" +
289- " }\n " +
290+ " }" +
290291 "}" , ContentType .APPLICATION_JSON );
291- client ().performRequest ("PUT" , "/child_example" , Collections .emptyMap (), parentMapping );
292+ client ().performRequest ("PUT" , "/" + indexName , Collections .emptyMap (), parentMapping );
292293 StringEntity questionDoc = new StringEntity ("{\n " +
293294 " \" body\" : \" <p>I have Windows 2003 server and i bought a new Windows 2008 server...\" ,\n " +
294295 " \" title\" : \" Whats the best way to file transfer my site from server to a newer one?\" ,\n " +
295296 " \" tags\" : [\n " +
296297 " \" windows-server-2003\" ,\n " +
297298 " \" windows-server-2008\" ,\n " +
298299 " \" file-transfer\" \n " +
299- " ]\n " +
300+ " ],\n " +
301+ " \" qa_join_field\" : \" question\" \n " +
300302 "}" , ContentType .APPLICATION_JSON );
301- client ().performRequest ("PUT" , "/child_example/question /1" , Collections .emptyMap (), questionDoc );
303+ client ().performRequest ("PUT" , "/" + indexName + "/qa /1" , Collections .emptyMap (), questionDoc );
302304 StringEntity answerDoc1 = new StringEntity ("{\n " +
303305 " \" owner\" : {\n " +
304306 " \" location\" : \" Norfolk, United Kingdom\" ,\n " +
305307 " \" display_name\" : \" Sam\" ,\n " +
306308 " \" id\" : 48\n " +
307309 " },\n " +
308310 " \" body\" : \" <p>Unfortunately you're pretty much limited to FTP...\" ,\n " +
311+ " \" qa_join_field\" : {\n " +
312+ " \" name\" : \" answer\" ,\n " +
313+ " \" parent\" : \" 1\" \n " +
314+ " },\n " +
309315 " \" creation_date\" : \" 2009-05-04T13:45:37.030\" \n " +
310316 "}" , ContentType .APPLICATION_JSON );
311- client ().performRequest ("PUT" , "child_example/answer/1 " , Collections .singletonMap ("parent " , "1" ), answerDoc1 );
317+ client ().performRequest ("PUT" , "/" + indexName + "/qa/2 " , Collections .singletonMap ("routing " , "1" ), answerDoc1 );
312318 StringEntity answerDoc2 = new StringEntity ("{\n " +
313319 " \" owner\" : {\n " +
314320 " \" location\" : \" Norfolk, United Kingdom\" ,\n " +
315321 " \" display_name\" : \" Troll\" ,\n " +
316322 " \" id\" : 49\n " +
317323 " },\n " +
318324 " \" body\" : \" <p>Use Linux...\" ,\n " +
325+ " \" qa_join_field\" : {\n " +
326+ " \" name\" : \" answer\" ,\n " +
327+ " \" parent\" : \" 1\" \n " +
328+ " },\n " +
319329 " \" creation_date\" : \" 2009-05-05T13:45:37.030\" \n " +
320330 "}" , ContentType .APPLICATION_JSON );
321- client ().performRequest ("PUT" , "/child_example/answer/2 " , Collections .singletonMap ("parent " , "1" ), answerDoc2 );
331+ client ().performRequest ("PUT" , "/" + indexName + "/qa/3 " , Collections .singletonMap ("routing " , "1" ), answerDoc2 );
322332 client ().performRequest ("POST" , "/_refresh" );
323333
324334 TermsAggregationBuilder leafTermAgg = new TermsAggregationBuilder ("top-names" , ValueType .STRING )
@@ -328,7 +338,7 @@ public void testSearchWithParentJoin() throws IOException {
328338 .size (10 ).subAggregation (childrenAgg );
329339 SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder ();
330340 searchSourceBuilder .size (0 ).aggregation (termsAgg );
331- SearchRequest searchRequest = new SearchRequest ("child_example" );
341+ SearchRequest searchRequest = new SearchRequest (indexName );
332342 searchRequest .source (searchSourceBuilder );
333343
334344 SearchResponse searchResponse = execute (searchRequest , highLevelClient ()::search , highLevelClient ()::searchAsync );
0 commit comments