42
42
* Testing the querying and parsing of inner_hits.
43
43
*
44
44
* @author Peter-Josef Meisch
45
+ * @author Jakob Hoeper
45
46
*/
46
47
@ SpringIntegrationTest
47
48
public abstract class InnerHitsIntegrationTests {
@@ -58,8 +59,9 @@ void setUp() {
58
59
indexOps .createWithMapping ();
59
60
60
61
Inhabitant john = new Inhabitant ("John" , "Smith" );
61
- Inhabitant carla = new Inhabitant ("Carla" , "Miller" );
62
- House cornerHouse = new House ("Round the corner" , "7" , Arrays .asList (john , carla ));
62
+ Inhabitant carla1 = new Inhabitant ("Carla" , "Miller" );
63
+ Inhabitant carla2 = new Inhabitant ("Carla" , "Nguyen" );
64
+ House cornerHouse = new House ("Round the corner" , "7" , Arrays .asList (john , carla1 , carla2 ));
63
65
City metropole = new City ("Metropole" , Arrays .asList (cornerHouse ));
64
66
65
67
Inhabitant jack = new Inhabitant ("Jack" , "Wayne" );
@@ -76,7 +78,7 @@ void cleanup() {
76
78
operations .indexOps (IndexCoordinates .of (indexNameProvider .getPrefix () + "*" )).delete ();
77
79
}
78
80
79
- @ Test
81
+ @ Test // #2521
80
82
void shouldReturnInnerHits () {
81
83
82
84
Query query = buildQueryForInnerHits ("inner_hit_name" , "hou-ses.in-habi-tants" , "hou-ses.in-habi-tants.first-name" ,
@@ -91,7 +93,7 @@ void shouldReturnInnerHits() {
91
93
softly .assertThat (searchHit .getInnerHits ()).hasSize (1 );
92
94
93
95
SearchHits <?> innerHits = searchHit .getInnerHits ("inner_hit_name" );
94
- softly .assertThat (innerHits ).hasSize (1 );
96
+ softly .assertThat (innerHits ).hasSize (2 );
95
97
96
98
SearchHit <?> innerHit = innerHits .getSearchHit (0 );
97
99
Object content = innerHit .getContent ();
@@ -106,6 +108,10 @@ void shouldReturnInnerHits() {
106
108
softly .assertThat (nestedMetaData .getChild ().getField ()).isEqualTo ("inhabitants" );
107
109
softly .assertThat (nestedMetaData .getChild ().getOffset ()).isEqualTo (1 );
108
110
111
+ innerHit = innerHits .getSearchHit (1 );
112
+ softly .assertThat (((Inhabitant ) innerHit .getContent ()).getLastName ()).isEqualTo ("Nguyen" );
113
+ softly .assertThat (innerHit .getNestedMetaData ().getChild ().getOffset ()).isEqualTo (2 );
114
+
109
115
softly .assertAll ();
110
116
}
111
117
0 commit comments