summaryrefslogtreecommitdiff
path: root/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java')
-rw-r--r--core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java37
1 files changed, 17 insertions, 20 deletions
diff --git a/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java b/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java
index 99f74d1f8e..91edc29160 100644
--- a/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java
+++ b/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java
@@ -36,7 +36,6 @@ import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.query.QueryBuilder;
-import org.elasticsearch.index.query.QueryParseContext;
import org.elasticsearch.index.query.QueryShardContext;
import org.elasticsearch.script.Script;
import org.elasticsearch.search.SearchExtBuilder;
@@ -109,9 +108,9 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
public static final ParseField SLICE = new ParseField("slice");
public static final ParseField ALL_FIELDS_FIELDS = new ParseField("all_fields");
- public static SearchSourceBuilder fromXContent(QueryParseContext context) throws IOException {
+ public static SearchSourceBuilder fromXContent(XContentParser parser) throws IOException {
SearchSourceBuilder builder = new SearchSourceBuilder();
- builder.parseXContent(context);
+ builder.parseXContent(parser);
return builder;
}
@@ -959,10 +958,9 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
/**
* Parse some xContent into this SearchSourceBuilder, overwriting any values specified in the xContent. Use this if you need to set up
* different defaults than a regular SearchSourceBuilder would have and use
- * {@link #fromXContent(QueryParseContext)} if you have normal defaults.
+ * {@link #fromXContent(XContentParser)} if you have normal defaults.
*/
- public void parseXContent(QueryParseContext context) throws IOException {
- XContentParser parser = context.parser();
+ public void parseXContent(XContentParser parser) throws IOException {
XContentParser.Token token = parser.currentToken();
String currentFieldName = null;
if (token != XContentParser.Token.START_OBJECT && (token = parser.nextToken()) != XContentParser.Token.START_OBJECT) {
@@ -992,10 +990,10 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
} else if (TRACK_TOTAL_HITS_FIELD.match(currentFieldName)) {
trackTotalHits = parser.booleanValue();
} else if (_SOURCE_FIELD.match(currentFieldName)) {
- fetchSourceContext = FetchSourceContext.fromXContent(context.parser());
+ fetchSourceContext = FetchSourceContext.fromXContent(parser);
} else if (STORED_FIELDS_FIELD.match(currentFieldName)) {
storedFieldsContext =
- StoredFieldsContext.fromXContent(SearchSourceBuilder.STORED_FIELDS_FIELD.getPreferredName(), context);
+ StoredFieldsContext.fromXContent(SearchSourceBuilder.STORED_FIELDS_FIELD.getPreferredName(), parser);
} else if (SORT_FIELD.match(currentFieldName)) {
sort(parser.text());
} else if (PROFILE_FIELD.match(currentFieldName)) {
@@ -1014,7 +1012,7 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
} else if (POST_FILTER_FIELD.match(currentFieldName)) {
postQueryBuilder = parseInnerQueryBuilder(parser);
} else if (_SOURCE_FIELD.match(currentFieldName)) {
- fetchSourceContext = FetchSourceContext.fromXContent(context.parser());
+ fetchSourceContext = FetchSourceContext.fromXContent(parser);
} else if (SCRIPT_FIELDS_FIELD.match(currentFieldName)) {
scriptFields = new ArrayList<>();
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
@@ -1035,16 +1033,16 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
}
} else if (AGGREGATIONS_FIELD.match(currentFieldName)
|| AGGS_FIELD.match(currentFieldName)) {
- aggregations = AggregatorFactories.parseAggregators(context);
+ aggregations = AggregatorFactories.parseAggregators(parser);
} else if (HIGHLIGHT_FIELD.match(currentFieldName)) {
highlightBuilder = HighlightBuilder.fromXContent(parser);
} else if (SUGGEST_FIELD.match(currentFieldName)) {
- suggestBuilder = SuggestBuilder.fromXContent(context.parser());
+ suggestBuilder = SuggestBuilder.fromXContent(parser);
} else if (SORT_FIELD.match(currentFieldName)) {
sorts = new ArrayList<>(SortBuilder.fromXContent(parser));
} else if (RESCORE_FIELD.match(currentFieldName)) {
rescoreBuilders = new ArrayList<>();
- rescoreBuilders.add(RescoreBuilder.parseFromXContent(context));
+ rescoreBuilders.add(RescoreBuilder.parseFromXContent(parser));
} else if (EXT_FIELD.match(currentFieldName)) {
extBuilders = new ArrayList<>();
String extSectionName = null;
@@ -1062,16 +1060,16 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
}
}
} else if (SLICE.match(currentFieldName)) {
- sliceBuilder = SliceBuilder.fromXContent(context);
+ sliceBuilder = SliceBuilder.fromXContent(parser);
} else if (COLLAPSE.match(currentFieldName)) {
- collapse = CollapseBuilder.fromXContent(context);
+ collapse = CollapseBuilder.fromXContent(parser);
} else {
throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].",
parser.getTokenLocation());
}
} else if (token == XContentParser.Token.START_ARRAY) {
if (STORED_FIELDS_FIELD.match(currentFieldName)) {
- storedFieldsContext = StoredFieldsContext.fromXContent(STORED_FIELDS_FIELD.getPreferredName(), context);
+ storedFieldsContext = StoredFieldsContext.fromXContent(STORED_FIELDS_FIELD.getPreferredName(), parser);
} else if (DOCVALUE_FIELDS_FIELD.match(currentFieldName)) {
docValueFields = new ArrayList<>();
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
@@ -1084,14 +1082,14 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
}
} else if (INDICES_BOOST_FIELD.match(currentFieldName)) {
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
- indexBoosts.add(new IndexBoost(context));
+ indexBoosts.add(new IndexBoost(parser));
}
} else if (SORT_FIELD.match(currentFieldName)) {
sorts = new ArrayList<>(SortBuilder.fromXContent(parser));
} else if (RESCORE_FIELD.match(currentFieldName)) {
rescoreBuilders = new ArrayList<>();
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
- rescoreBuilders.add(RescoreBuilder.parseFromXContent(context));
+ rescoreBuilders.add(RescoreBuilder.parseFromXContent(parser));
}
} else if (STATS_FIELD.match(currentFieldName)) {
stats = new ArrayList<>();
@@ -1104,7 +1102,7 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
}
}
} else if (_SOURCE_FIELD.match(currentFieldName)) {
- fetchSourceContext = FetchSourceContext.fromXContent(context.parser());
+ fetchSourceContext = FetchSourceContext.fromXContent(parser);
} else if (SEARCH_AFTER.match(currentFieldName)) {
searchAfterBuilder = SearchAfterBuilder.fromXContent(parser);
} else if (FIELDS_FIELD.match(currentFieldName)) {
@@ -1276,8 +1274,7 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
boost = in.readFloat();
}
- IndexBoost(QueryParseContext context) throws IOException {
- XContentParser parser = context.parser();
+ IndexBoost(XContentParser parser) throws IOException {
XContentParser.Token token = parser.currentToken();
if (token == XContentParser.Token.START_OBJECT) {