Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@

import org.apache.http.entity.ContentType;
import org.apache.http.nio.entity.NStringEntity;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.Version;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.client.Request;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
Expand All @@ -53,6 +55,13 @@
* because the version constants have been removed.
*/
final class RemoteRequestBuilders {
private static final DeprecationLogger DEPRECATION_LOGGER
= new DeprecationLogger(LogManager.getLogger(RemoteRequestBuilders.class));

static final String DEPRECATED_URL_ENCODED_INDEX_WARNING =
"Specifying index name using URL escaped index names for reindex from remote is deprecated. " +
"Instead specify index name without URL escaping.";

private RemoteRequestBuilders() {}

static Request initialSearch(SearchRequest searchRequest, BytesReference query, Version remoteVersion) {
Expand Down Expand Up @@ -173,6 +182,7 @@ private static void addIndices(StringBuilder path, String[] indices) {
private static String encodeIndex(String s) {
if (s.contains("%")) { // already encoded, pass-through to allow this in mixed version clusters
checkIndexOrType("Index", s);
DEPRECATION_LOGGER.deprecated(DEPRECATED_URL_ENCODED_INDEX_WARNING);
return s;
}
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.util.Map;

import static org.elasticsearch.common.unit.TimeValue.timeValueMillis;
import static org.elasticsearch.index.reindex.remote.RemoteRequestBuilders.DEPRECATED_URL_ENCODED_INDEX_WARNING;
import static org.elasticsearch.index.reindex.remote.RemoteRequestBuilders.clearScroll;
import static org.elasticsearch.index.reindex.remote.RemoteRequestBuilders.initialSearch;
import static org.elasticsearch.index.reindex.remote.RemoteRequestBuilders.scroll;
Expand Down Expand Up @@ -83,6 +84,8 @@ public void testIntialSearchPath() {
searchRequest.indices("%2f", "%3a");
assertEquals("/%2f,%3a/c,d/_search", initialSearch(searchRequest, query, remoteVersion).getEndpoint());

assertWarnings(DEPRECATED_URL_ENCODED_INDEX_WARNING);

// do not allow , and / if already escaped.
searchRequest.indices("%2fcat,");
expectBadStartRequest(searchRequest, "Index", ",", "%2fcat,");
Expand Down