|
@@ -28,6 +28,7 @@ import org.elasticsearch.xpack.core.transform.transforms.pivot.GeoTileGroupSourc
|
|
|
import org.elasticsearch.xpack.core.transform.transforms.pivot.GroupConfig;
|
|
|
import org.elasticsearch.xpack.core.transform.transforms.pivot.GroupConfigTests;
|
|
|
import org.elasticsearch.xpack.core.transform.transforms.pivot.HistogramGroupSourceTests;
|
|
|
+import org.elasticsearch.xpack.core.transform.transforms.pivot.ScriptConfigTests;
|
|
|
import org.elasticsearch.xpack.core.transform.transforms.pivot.SingleGroupSource;
|
|
|
import org.elasticsearch.xpack.core.transform.transforms.pivot.TermsGroupSource;
|
|
|
import org.elasticsearch.xpack.core.transform.transforms.pivot.TermsGroupSourceTests;
|
|
@@ -80,7 +81,7 @@ public class CompositeBucketsChangeCollectorTests extends ESTestCase {
|
|
|
assertEquals(10, getCompositeAggregationBuilder(collector.buildChangesQuery(new SearchSourceBuilder(), null, 10)).size());
|
|
|
|
|
|
// a terms group_by is limited by terms query
|
|
|
- SingleGroupSource termsGroupBy = TermsGroupSourceTests.randomTermsGroupSource();
|
|
|
+ SingleGroupSource termsGroupBy = TermsGroupSourceTests.randomTermsGroupSourceNoScript();
|
|
|
groups.put("terms", termsGroupBy);
|
|
|
|
|
|
collector = CompositeBucketsChangeCollector.buildChangeCollector(getCompositeAggregation(groups), groups, null);
|
|
@@ -196,6 +197,24 @@ public class CompositeBucketsChangeCollectorTests extends ESTestCase {
|
|
|
assertNull(queryBuilder);
|
|
|
}
|
|
|
|
|
|
+ public void testNoTermsFieldCollectorForScripts() throws IOException {
|
|
|
+ Map<String, SingleGroupSource> groups = new LinkedHashMap<>();
|
|
|
+
|
|
|
+ // terms with value script
|
|
|
+ SingleGroupSource termsGroupBy = new TermsGroupSource("id", ScriptConfigTests.randomScriptConfig(), false);
|
|
|
+ groups.put("id", termsGroupBy);
|
|
|
+
|
|
|
+ Map<String, FieldCollector> fieldCollectors = CompositeBucketsChangeCollector.createFieldCollectors(groups, null);
|
|
|
+ assertTrue(fieldCollectors.isEmpty());
|
|
|
+
|
|
|
+ // terms with only a script
|
|
|
+ termsGroupBy = new TermsGroupSource(null, ScriptConfigTests.randomScriptConfig(), false);
|
|
|
+ groups.put("id", termsGroupBy);
|
|
|
+
|
|
|
+ fieldCollectors = CompositeBucketsChangeCollector.createFieldCollectors(groups, null);
|
|
|
+ assertTrue(fieldCollectors.isEmpty());
|
|
|
+ }
|
|
|
+
|
|
|
private static CompositeAggregationBuilder getCompositeAggregation(Map<String, SingleGroupSource> groups) throws IOException {
|
|
|
CompositeAggregationBuilder compositeAggregation;
|
|
|
try (XContentBuilder builder = jsonBuilder()) {
|