|
32 | 32 | import org.apache.lucene.search.TermInSetQuery;
|
33 | 33 | import org.apache.lucene.store.Directory;
|
34 | 34 | import org.apache.lucene.util.BytesRef;
|
35 |
| -import org.apache.lucene.util.LuceneTestCase; |
36 | 35 | import org.elasticsearch.Version;
|
37 | 36 | import org.elasticsearch.cluster.metadata.IndexMetadata;
|
38 | 37 | import org.elasticsearch.common.collect.Tuple;
|
39 | 38 | import org.elasticsearch.common.lucene.index.ElasticsearchDirectoryReader;
|
40 | 39 | import org.elasticsearch.common.settings.Settings;
|
41 | 40 | import org.elasticsearch.index.Index;
|
42 | 41 | import org.elasticsearch.index.mapper.ContentPath;
|
43 |
| -import org.elasticsearch.index.mapper.MappingLookup; |
44 | 42 | import org.elasticsearch.index.mapper.DocumentMapper;
|
45 | 43 | import org.elasticsearch.index.mapper.IdFieldMapper;
|
46 | 44 | import org.elasticsearch.index.mapper.MappedFieldType;
|
47 | 45 | import org.elasticsearch.index.mapper.Mapper;
|
48 | 46 | import org.elasticsearch.index.mapper.MapperService;
|
| 47 | +import org.elasticsearch.index.mapper.MappingLookup; |
49 | 48 | import org.elasticsearch.index.mapper.NumberFieldMapper;
|
50 | 49 | import org.elasticsearch.index.mapper.Uid;
|
51 | 50 | import org.elasticsearch.index.shard.ShardId;
|
|
75 | 74 | import static org.mockito.Mockito.mock;
|
76 | 75 | import static org.mockito.Mockito.when;
|
77 | 76 |
|
78 |
| -@LuceneTestCase.AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/60980") |
79 | 77 | public class ChildrenToParentAggregatorTests extends AggregatorTestCase {
|
80 | 78 |
|
81 | 79 | private static final String CHILD_TYPE = "child_type";
|
@@ -121,9 +119,11 @@ public void testParentChild() throws IOException {
|
121 | 119 | expectedTotalParents++;
|
122 | 120 | expectedMinValue = Math.min(expectedMinValue, expectedValues.v2());
|
123 | 121 | }
|
124 |
| - assertEquals("Having " + parent.getDocCount() + " docs and aggregation results: " + |
125 |
| - parent.getAggregations().asMap(), |
126 |
| - expectedTotalParents, parent.getDocCount()); |
| 122 | + assertEquals( |
| 123 | + "Having " + parent.getDocCount() + " docs and aggregation results: " + parent, |
| 124 | + expectedTotalParents, |
| 125 | + parent.getDocCount() |
| 126 | + ); |
127 | 127 | assertEquals(expectedMinValue, ((InternalMin) parent.getAggregations().get("in_parent")).getValue(), Double.MIN_VALUE);
|
128 | 128 | assertTrue(JoinAggregationInspectionHelper.hasValue(parent));
|
129 | 129 | });
|
@@ -235,21 +235,19 @@ private static Map<String, Tuple<Integer, Integer>> setupIndex(RandomIndexWriter
|
235 | 235 | Map<String, Tuple<Integer, Integer>> expectedValues = new HashMap<>();
|
236 | 236 | int numParents = randomIntBetween(1, 10);
|
237 | 237 | for (int i = 0; i < numParents; i++) {
|
| 238 | + List<List<Field>> documents = new ArrayList<>(); |
238 | 239 | String parent = "parent" + i;
|
239 | 240 | int randomValue = randomIntBetween(0, 100);
|
240 |
| - List<Field> parentDocument = createParentDocument(parent, randomValue); |
241 |
| - /*long parentDocId =*/ iw.addDocument(parentDocument); |
242 |
| - //System.out.println("Parent: " + parent + ": " + randomValue + ", id: " + parentDocId); |
| 241 | + documents.add(createParentDocument(parent, randomValue)); |
243 | 242 | int numChildren = randomIntBetween(1, 10);
|
244 | 243 | int minValue = Integer.MAX_VALUE;
|
245 | 244 | for (int c = 0; c < numChildren; c++) {
|
246 | 245 | minValue = Math.min(minValue, randomValue);
|
247 | 246 | int randomSubValue = randomIntBetween(0, 100);
|
248 |
| - List<Field> childDocument = createChildDocument("child" + c + "_" + parent, parent, randomSubValue); |
249 |
| - /*long childDocId =*/ iw.addDocument(childDocument); |
250 |
| - //System.out.println("Child: " + "child" + c + "_" + parent + ": " + randomSubValue + ", id: " + childDocId); |
| 247 | + documents.add(createChildDocument("child" + c + "_" + parent, parent, randomSubValue)); |
251 | 248 | }
|
252 | 249 | expectedValues.put(parent, new Tuple<>(numChildren, minValue));
|
| 250 | + iw.addDocuments(documents); |
253 | 251 | }
|
254 | 252 | return expectedValues;
|
255 | 253 | }
|
|
0 commit comments