Skip to content

Commit d02487e

Browse files
authored
Field caps to support project_routing also in the body of the request (#138681)
* Field caps to support project_routing also in the body of the request * Update docs/changelog/138681.yaml
1 parent d90d76a commit d02487e

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

docs/changelog/138681.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 138681
2+
summary: Field caps to support `project_routing` also in the body of the request
3+
area: Search
4+
type: enhancement
5+
issues: []

server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesRequest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,10 @@ public ResolvedIndexExpressions getResolvedIndexExpressions() {
280280
return resolvedIndexExpressions;
281281
}
282282

283-
public void projectRouting(String projectRouting) {
283+
public void projectRouting(@Nullable String projectRouting) {
284+
if (this.projectRouting != null) {
285+
throw new IllegalArgumentException("project_routing is already set to [" + this.projectRouting + "]");
286+
}
284287
this.projectRouting = projectRouting;
285288
}
286289

server/src/main/java/org/elasticsearch/rest/action/RestFieldCapabilitiesAction.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,14 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
107107
private static final ParseField INDEX_FILTER_FIELD = new ParseField("index_filter");
108108
private static final ParseField RUNTIME_MAPPINGS_FIELD = new ParseField("runtime_mappings");
109109
private static final ParseField FIELDS_FIELD = new ParseField("fields");
110+
private static final ParseField PROJECT_ROUTING = new ParseField("project_routing");
110111

111112
private static final ObjectParser<FieldCapabilitiesRequest, Void> PARSER = new ObjectParser<>("field_caps_request");
112113

113114
static {
114115
PARSER.declareObject(FieldCapabilitiesRequest::indexFilter, (p, c) -> parseTopLevelQuery(p), INDEX_FILTER_FIELD);
115116
PARSER.declareObject(FieldCapabilitiesRequest::runtimeFields, (p, c) -> p.map(), RUNTIME_MAPPINGS_FIELD);
116117
PARSER.declareStringArray(fromList(String.class, FieldCapabilitiesRequest::fields), FIELDS_FIELD);
118+
PARSER.declareString(FieldCapabilitiesRequest::projectRouting, PROJECT_ROUTING);
117119
}
118120
}

0 commit comments

Comments
 (0)