|
25 | 25 | import org.elasticsearch.xpack.core.transform.transforms.pivot.GroupConfig;
|
26 | 26 | import org.elasticsearch.xpack.core.transform.transforms.pivot.GroupConfigTests;
|
27 | 27 | import org.elasticsearch.xpack.core.transform.transforms.pivot.HistogramGroupSourceTests;
|
| 28 | +import org.elasticsearch.xpack.core.transform.transforms.pivot.ScriptConfigTests; |
28 | 29 | import org.elasticsearch.xpack.core.transform.transforms.pivot.SingleGroupSource;
|
29 | 30 | import org.elasticsearch.xpack.core.transform.transforms.pivot.TermsGroupSource;
|
30 | 31 | import org.elasticsearch.xpack.core.transform.transforms.pivot.TermsGroupSourceTests;
|
@@ -76,7 +77,7 @@ public void testPageSize() throws IOException {
|
76 | 77 | assertEquals(10, getCompositeAggregationBuilder(collector.buildChangesQuery(new SearchSourceBuilder(), null, 10)).size());
|
77 | 78 |
|
78 | 79 | // a terms group_by is limited by terms query
|
79 |
| - SingleGroupSource termsGroupBy = TermsGroupSourceTests.randomTermsGroupSource(); |
| 80 | + SingleGroupSource termsGroupBy = TermsGroupSourceTests.randomTermsGroupSourceNoScript(); |
80 | 81 | groups.put("terms", termsGroupBy);
|
81 | 82 |
|
82 | 83 | collector = CompositeBucketsChangeCollector.buildChangeCollector(getCompositeAggregation(groups), groups, null);
|
@@ -138,6 +139,24 @@ public void testTermsFieldCollector() throws IOException {
|
138 | 139 | assertThat(((TermsQueryBuilder) queryBuilder).values(), containsInAnyOrder("id1", "id2", "id3"));
|
139 | 140 | }
|
140 | 141 |
|
| 142 | + public void testNoTermsFieldCollectorForScripts() throws IOException { |
| 143 | + Map<String, SingleGroupSource> groups = new LinkedHashMap<>(); |
| 144 | + |
| 145 | + // terms with value script |
| 146 | + SingleGroupSource termsGroupBy = new TermsGroupSource("id", ScriptConfigTests.randomScriptConfig()); |
| 147 | + groups.put("id", termsGroupBy); |
| 148 | + |
| 149 | + Map<String, FieldCollector> fieldCollectors = CompositeBucketsChangeCollector.createFieldCollectors(groups, null); |
| 150 | + assertTrue(fieldCollectors.isEmpty()); |
| 151 | + |
| 152 | + // terms with only a script |
| 153 | + termsGroupBy = new TermsGroupSource(null, ScriptConfigTests.randomScriptConfig()); |
| 154 | + groups.put("id", termsGroupBy); |
| 155 | + |
| 156 | + fieldCollectors = CompositeBucketsChangeCollector.createFieldCollectors(groups, null); |
| 157 | + assertTrue(fieldCollectors.isEmpty()); |
| 158 | + } |
| 159 | + |
141 | 160 | private static CompositeAggregationBuilder getCompositeAggregation(Map<String, SingleGroupSource> groups) throws IOException {
|
142 | 161 | CompositeAggregationBuilder compositeAggregation;
|
143 | 162 | try (XContentBuilder builder = jsonBuilder()) {
|
|
0 commit comments