diff options
Diffstat (limited to 'core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregatorFactory.java')
-rw-r--r-- | core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregatorFactory.java | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregatorFactory.java b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregatorFactory.java index 5dff86c5ee..42477c3212 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregatorFactory.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregatorFactory.java @@ -31,6 +31,7 @@ import org.elasticsearch.search.builder.SearchSourceBuilder.ScriptField; import org.elasticsearch.search.fetch.StoredFieldsContext; import org.elasticsearch.search.fetch.subphase.DocValueFieldsContext; import org.elasticsearch.search.fetch.subphase.FetchSourceContext; +import org.elasticsearch.search.fetch.subphase.ScriptFieldsContext; import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder; import org.elasticsearch.search.internal.SubSearchContext; import org.elasticsearch.search.sort.SortAndFormats; @@ -54,14 +55,14 @@ public class TopHitsAggregatorFactory extends AggregatorFactory<TopHitsAggregato private final HighlightBuilder highlightBuilder; private final StoredFieldsContext storedFieldsContext; private final List<String> docValueFields; - private final Set<ScriptField> scriptFields; + private final List<ScriptFieldsContext.ScriptField> scriptFields; private final FetchSourceContext fetchSourceContext; public TopHitsAggregatorFactory(String name, Type type, int from, int size, boolean explain, boolean version, boolean trackScores, - List<SortBuilder<?>> sorts, HighlightBuilder highlightBuilder, StoredFieldsContext storedFieldsContext, - List<String> docValueFields, Set<ScriptField> scriptFields, FetchSourceContext fetchSourceContext, - AggregationContext context, AggregatorFactory<?> parent, AggregatorFactories.Builder subFactories, - Map<String, Object> metaData) throws IOException { + List<SortBuilder<?>> sorts, HighlightBuilder highlightBuilder, StoredFieldsContext storedFieldsContext, + List<String> docValueFields, List<ScriptFieldsContext.ScriptField> scriptFields, FetchSourceContext fetchSourceContext, + AggregationContext context, AggregatorFactory<?> parent, AggregatorFactories.Builder subFactories, + Map<String, Object> metaData) throws IOException { super(name, type, context, parent, subFactories, metaData); this.from = from; this.size = size; @@ -99,12 +100,8 @@ public class TopHitsAggregatorFactory extends AggregatorFactory<TopHitsAggregato subSearchContext.docValueFieldsContext(new DocValueFieldsContext(docValueFields)); } if (scriptFields != null) { - subSearchContext.markAsNotCachable(); - for (ScriptField field : scriptFields) { - SearchScript searchScript = subSearchContext.scriptService().search(subSearchContext.lookup(), field.script(), - ScriptContext.Standard.SEARCH, Collections.emptyMap()); - subSearchContext.scriptFields().add(new org.elasticsearch.search.fetch.subphase.ScriptFieldsContext.ScriptField( - field.fieldName(), searchScript, field.ignoreFailure())); + for (ScriptFieldsContext.ScriptField field : scriptFields) { + subSearchContext.scriptFields().add(field); } } if (fetchSourceContext != null) { |