|
10 | 10 |
|
11 | 11 | import org.elasticsearch.ElasticsearchException; |
12 | 12 | import org.elasticsearch.Version; |
| 13 | +import org.elasticsearch.common.logging.DeprecationLogger; |
13 | 14 | import org.elasticsearch.core.Booleans; |
14 | 15 | import org.elasticsearch.core.Nullable; |
15 | 16 | import org.elasticsearch.common.xcontent.ParseField; |
|
18 | 19 | import org.elasticsearch.common.io.stream.StreamInput; |
19 | 20 | import org.elasticsearch.common.io.stream.StreamOutput; |
20 | 21 | import org.elasticsearch.common.io.stream.Writeable; |
| 22 | +import org.elasticsearch.core.RestApiVersion; |
21 | 23 | import org.elasticsearch.core.TimeValue; |
22 | 24 | import org.elasticsearch.common.xcontent.ToXContentFragment; |
23 | 25 | import org.elasticsearch.common.xcontent.ToXContentObject; |
|
68 | 70 | * @see org.elasticsearch.action.search.SearchRequest#source(SearchSourceBuilder) |
69 | 71 | */ |
70 | 72 | public final class SearchSourceBuilder implements Writeable, ToXContentObject, Rewriteable<SearchSourceBuilder> { |
| 73 | + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(SearchSourceBuilder.class); |
| 74 | + |
71 | 75 | public static final ParseField FROM_FIELD = new ParseField("from"); |
72 | 76 | public static final ParseField SIZE_FIELD = new ParseField("size"); |
73 | 77 | public static final ParseField TIMEOUT_FIELD = new ParseField("timeout"); |
@@ -1164,6 +1168,20 @@ public void parseXContent(XContentParser parser, boolean checkTrailingTokens) th |
1164 | 1168 | while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { |
1165 | 1169 | scriptFields.add(new ScriptField(parser)); |
1166 | 1170 | } |
| 1171 | + } else if (parser.getRestApiVersion() == RestApiVersion.V_7 && |
| 1172 | + INDICES_BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { |
| 1173 | + deprecationLogger.compatibleApiWarning("indices_boost_object_format", |
| 1174 | + "Object format in indices_boost is deprecated, please use array format instead"); |
| 1175 | + while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { |
| 1176 | + if (token == XContentParser.Token.FIELD_NAME) { |
| 1177 | + currentFieldName = parser.currentName(); |
| 1178 | + } else if (token.isValue()) { |
| 1179 | + indexBoosts.add(new IndexBoost(currentFieldName, parser.floatValue())); |
| 1180 | + } else { |
| 1181 | + throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + |
| 1182 | + " in [" + currentFieldName + "].", parser.getTokenLocation()); |
| 1183 | + } |
| 1184 | + } |
1167 | 1185 | } else if (AGGREGATIONS_FIELD.match(currentFieldName, parser.getDeprecationHandler()) |
1168 | 1186 | || AGGS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { |
1169 | 1187 | aggregations = AggregatorFactories.parseAggregators(parser); |
|
0 commit comments