Skip to content

Commit 23a1c66

Browse files
Warn only once per multisearch request
1 parent c7a1ad4 commit 23a1c66

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

server/src/main/java/org/elasticsearch/action/search/MultiSearchRequest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
import org.elasticsearch.common.bytes.BytesReference;
1919
import org.elasticsearch.common.io.stream.StreamInput;
2020
import org.elasticsearch.common.io.stream.StreamOutput;
21+
import org.elasticsearch.common.logging.HeaderWarning;
2122
import org.elasticsearch.common.xcontent.XContentHelper;
23+
import org.elasticsearch.rest.action.search.SearchParamsParser;
2224
import org.elasticsearch.tasks.CancellableTask;
2325
import org.elasticsearch.tasks.Task;
2426
import org.elasticsearch.tasks.TaskId;
@@ -204,6 +206,7 @@ public static void readMultiLineFormat(
204206
) throws IOException {
205207
int from = 0;
206208
byte marker = xContent.bulkSeparator();
209+
boolean warnedMrtForCps = false;
207210
while (true) {
208211
int nextMarker = findNextMarker(marker, from, data);
209212
if (nextMarker == -1) {
@@ -256,6 +259,10 @@ public static void readMultiLineFormat(
256259
searchRequest.searchType(nodeStringValue(value, null));
257260
} else if ("ccs_minimize_roundtrips".equals(entry.getKey()) || "ccsMinimizeRoundtrips".equals(entry.getKey())) {
258261
searchRequest.setCcsMinimizeRoundtrips(crossProjectEnabled.orElse(false) || nodeBooleanValue(value));
262+
if (warnedMrtForCps == false) {
263+
HeaderWarning.addWarning(SearchParamsParser.MRT_SET_IN_CPS_WARN);
264+
warnedMrtForCps = true;
265+
}
259266
} else if ("request_cache".equals(entry.getKey()) || "requestCache".equals(entry.getKey())) {
260267
searchRequest.requestCache(nodeBooleanValue(value, entry.getKey()));
261268
} else if ("preference".equals(entry.getKey())) {

server/src/main/java/org/elasticsearch/rest/action/search/SearchParamsParser.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
import java.util.Optional;
1616

1717
public class SearchParamsParser {
18-
private static final String MRT_SET_IN_CPS_WARN = "ccs_minimize_roundtrips always defaults to true in Cross Project Search context."
19-
+ " Setting it explicitly has no effect irrespective of the value specified and is ignored.";
18+
public static final String MRT_SET_IN_CPS_WARN = "ccs_minimize_roundtrips always defaults to true in Cross Project Search context."
19+
+ " Setting it explicitly has no effect irrespective of the value specified and is ignored."
20+
+ " It will soon be deprecated and made unavailable for Cross project Search.";
2021

2122
/**
2223
* For CPS, we do not necessarily want to use the MRT value that the user has provided.

0 commit comments

Comments
 (0)