From f8a7bed4f0b925345d12a676af60973b536f0915 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Sun, 21 Feb 2016 18:08:20 -0800 Subject: [PATCH] Highlighter: Move xContent write of highlight fieldname to SearchSourceBuilder Most elements in SearchSourceBuilder (e.g. aggs, queries) write their top-level ParseField name in toXContent(), while HighlightBuilder used to do it in its own toXContent() method. Moved this up so SeachSourceBuilder for consistency. --- .../action/percolate/PercolateSourceBuilder.java | 3 ++- .../metrics/tophits/TopHitsAggregatorBuilder.java | 4 ++-- .../org/elasticsearch/search/builder/SearchSourceBuilder.java | 2 +- .../org/elasticsearch/search/highlight/HighlightBuilder.java | 4 +--- .../elasticsearch/search/highlight/HighlightBuilderTests.java | 4 +--- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/action/percolate/PercolateSourceBuilder.java b/core/src/main/java/org/elasticsearch/action/percolate/PercolateSourceBuilder.java index 9d52c96f969..d687d48fb0c 100644 --- a/core/src/main/java/org/elasticsearch/action/percolate/PercolateSourceBuilder.java +++ b/core/src/main/java/org/elasticsearch/action/percolate/PercolateSourceBuilder.java @@ -31,6 +31,7 @@ import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.search.aggregations.AggregatorBuilder; import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder; +import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.search.highlight.HighlightBuilder; import org.elasticsearch.search.sort.ScoreSortBuilder; import org.elasticsearch.search.sort.SortBuilder; @@ -170,7 +171,7 @@ public class PercolateSourceBuilder extends ToXContentToBytes { builder.field("track_scores", trackScores); } if (highlightBuilder != null) { - highlightBuilder.toXContent(builder, params); + builder.field(SearchSourceBuilder.HIGHLIGHT_FIELD.getPreferredName(), highlightBuilder); } if (aggregationBuilders != null || pipelineAggregationBuilders != null) { builder.field("aggregations"); diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregatorBuilder.java b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregatorBuilder.java index a15a61eaae2..9f5f3e443ef 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregatorBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregatorBuilder.java @@ -31,8 +31,8 @@ import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.script.Script; import org.elasticsearch.search.aggregations.AggregationInitializationException; import org.elasticsearch.search.aggregations.AggregatorBuilder; -import org.elasticsearch.search.aggregations.AggregatorFactory; import org.elasticsearch.search.aggregations.AggregatorFactories.Builder; +import org.elasticsearch.search.aggregations.AggregatorFactory; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.search.builder.SearchSourceBuilder.ScriptField; @@ -520,7 +520,7 @@ public class TopHitsAggregatorBuilder extends AggregatorBuilder