Skip to content

POC: SPI for CPS #130679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
import org.elasticsearch.search.SearchService;
import org.elasticsearch.search.SearchUtils;
import org.elasticsearch.search.aggregations.support.AggregationUsageService;
import org.elasticsearch.search.internal.CrossClusterSearchExtension;
import org.elasticsearch.shutdown.PluginShutdownService;
import org.elasticsearch.snapshots.InternalSnapshotsInfoService;
import org.elasticsearch.snapshots.RepositoryIntegrityHealthIndicatorService;
Expand Down Expand Up @@ -1015,6 +1016,13 @@ public Map<String, String> queryFields() {

var reservedStateHandlerProviders = pluginsService.loadServiceProviders(ReservedStateHandlerProvider.class);

var crossClusterSearchExtension = pluginsService.loadSingletonServiceProvider(
CrossClusterSearchExtension.class,
CrossClusterSearchExtension.Default::new
);

logger.info("Cross-cluster example: [{}]", crossClusterSearchExtension.indicesExpressionRewriter().getClass());

ActionModule actionModule = new ActionModule(
settings,
clusterModule.getIndexNameExpressionResolver(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

package org.elasticsearch.search.internal;

import org.elasticsearch.action.IndicesRequest;

public interface CrossClusterSearchExtension {

IndicesExpressionRewriter indicesExpressionRewriter();

interface IndicesExpressionRewriter {
IndicesRequest.Replaceable rewrite(IndicesRequest.Replaceable request);
}

class Default implements CrossClusterSearchExtension {
public Default() {}

@Override
public IndicesExpressionRewriter indicesExpressionRewriter() {
return request -> {
// Default implementation does nothing, can be overridden by extensions
return request;
};
}
}
}