Skip to content

Commit cd878bd

Browse files
committed
Allow CCS only when ccs_minimize_roundtrips=true
1 parent 43dda15 commit cd878bd

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/queries/SemanticQueryBuilder.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
import static org.elasticsearch.xpack.core.ClientHelper.ML_ORIGIN;
5353
import static org.elasticsearch.xpack.core.ClientHelper.executeAsyncWithOrigin;
5454

55-
// TODO: Only allow CCS when ccs_minimize_roundtrips=true
5655
// TODO: Add flag to perform inference again during remote cluster coordinator rewrite
5756

5857
public class SemanticQueryBuilder extends AbstractQueryBuilder<SemanticQueryBuilder> {
@@ -252,6 +251,10 @@ private SemanticQueryBuilder doRewriteGetInferenceResults(QueryRewriteContext qu
252251
throw new IllegalStateException(
253252
"Rewriting on the coordinator node requires a query rewrite context with non-null resolved indices"
254253
);
254+
} else if (resolvedIndices.getRemoteClusterIndices().isEmpty() == false) {
255+
if (queryRewriteContext.isCcsMinimizeRoundtrips() != true) {
256+
throw new IllegalArgumentException(NAME + " query supports CCS only when ccs_minimize_roundtrips=true");
257+
}
255258
}
256259

257260
Set<String> inferenceIds = getInferenceIdsForForField(resolvedIndices.getConcreteLocalIndicesMetadata().values(), fieldName);

0 commit comments

Comments
 (0)