From aeed7ee2187216db7bb0ea0bbfe8f3feb85cd85e Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Mon, 29 Feb 2016 14:57:16 -0500 Subject: [PATCH] Reindex: rename source to searchRequest This makes the code easier to read for those familiar with the Elasticsearch code base. --- .../reindex/AbstractBulkByScrollRequest.java | 26 +++++++++---------- .../index/reindex/ReindexRequest.java | 2 +- .../index/reindex/RestReindexAction.java | 2 +- .../reindex/RestUpdateByQueryAction.java | 10 +++---- .../index/reindex/TransportReindexAction.java | 4 +-- .../reindex/TransportUpdateByQueryAction.java | 2 +- .../index/reindex/RoundTripTests.java | 8 +++--- 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/AbstractBulkByScrollRequest.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/AbstractBulkByScrollRequest.java index b7d09389581..41b436e6074 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/AbstractBulkByScrollRequest.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/AbstractBulkByScrollRequest.java @@ -46,7 +46,7 @@ public abstract class AbstractBulkByScrollRequest i.ttl(parseTimeValue(ttl, TimeValue.timeValueMillis(-1), "ttl").millis()), new ParseField("ttl")); - PARSER.declareField((p, v, c) -> sourceParser.parse(p, v.getSource(), c), new ParseField("source"), ValueType.OBJECT); + PARSER.declareField((p, v, c) -> sourceParser.parse(p, v.getSearchRequest(), c), new ParseField("source"), ValueType.OBJECT); PARSER.declareField((p, v, c) -> destParser.parse(p, v.getDestination(), null), new ParseField("dest"), ValueType.OBJECT); PARSER.declareInt(ReindexRequest::setSize, new ParseField("size")); PARSER.declareField((p, v, c) -> v.setScript(Script.parse(p, c.queryParseContext.parseFieldMatcher())), new ParseField("script"), diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestUpdateByQueryAction.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestUpdateByQueryAction.java index 1d732a0c5f4..c6e8aa325dd 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestUpdateByQueryAction.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestUpdateByQueryAction.java @@ -64,8 +64,8 @@ public class RestUpdateByQueryAction extends * defaults. Then the parse can override them. */ UpdateByQueryRequest internalRequest = new UpdateByQueryRequest(new SearchRequest()); - int scrollSize = internalRequest.getSource().source().size(); - internalRequest.getSource().source().size(SIZE_ALL_MATCHES); + int scrollSize = internalRequest.getSearchRequest().source().size(); + internalRequest.getSearchRequest().source().size(SIZE_ALL_MATCHES); /* * We can't send parseSearchRequest REST content that it doesn't support * so we will have to remove the content that is valid in addition to @@ -95,7 +95,7 @@ public class RestUpdateByQueryAction extends bodyContent = builder.bytes(); } } - RestSearchAction.parseSearchRequest(internalRequest.getSource(), indicesQueriesRegistry, request, + RestSearchAction.parseSearchRequest(internalRequest.getSearchRequest(), indicesQueriesRegistry, request, parseFieldMatcher, aggParsers, bodyContent); String conflicts = request.param("conflicts"); @@ -104,8 +104,8 @@ public class RestUpdateByQueryAction extends } parseCommon(internalRequest, request); - internalRequest.setSize(internalRequest.getSource().source().size()); - internalRequest.getSource().source().size(request.paramAsInt("scroll_size", scrollSize)); + internalRequest.setSize(internalRequest.getSearchRequest().source().size()); + internalRequest.getSearchRequest().source().size(request.paramAsInt("scroll_size", scrollSize)); execute(request, internalRequest, channel); } diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/TransportReindexAction.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/TransportReindexAction.java index 1424b53e07a..4c7b14e4970 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/TransportReindexAction.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/TransportReindexAction.java @@ -71,7 +71,7 @@ public class TransportReindexAction extends HandledTransportAction listener) { - validateAgainstAliases(request.getSource(), request.getDestination(), indexNameExpressionResolver, autoCreateIndex, + validateAgainstAliases(request.getSearchRequest(), request.getDestination(), indexNameExpressionResolver, autoCreateIndex, clusterService.state()); new AsyncIndexBySearchAction((BulkByScrollTask) task, logger, scriptService, client, threadPool, request, listener).start(); } @@ -117,7 +117,7 @@ public class TransportReindexAction extends HandledTransportAction { public AsyncIndexBySearchAction(BulkByScrollTask task, ESLogger logger, ScriptService scriptService, Client client, ThreadPool threadPool, ReindexRequest request, ActionListener listener) { - super(task, logger, scriptService, client, threadPool, request, request.getSource(), listener); + super(task, logger, scriptService, client, threadPool, request, request.getSearchRequest(), listener); } @Override diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/TransportUpdateByQueryAction.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/TransportUpdateByQueryAction.java index 29deca8f309..0fd80fec2a9 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/TransportUpdateByQueryAction.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/TransportUpdateByQueryAction.java @@ -78,7 +78,7 @@ public class TransportUpdateByQueryAction extends HandledTransportAction { public AsyncIndexBySearchAction(BulkByScrollTask task, ESLogger logger, ScriptService scriptService, Client client, ThreadPool threadPool, UpdateByQueryRequest request, ActionListener listener) { - super(task, logger, scriptService, client, threadPool, request, request.getSource(), listener); + super(task, logger, scriptService, client, threadPool, request, request.getSearchRequest(), listener); } @Override diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/RoundTripTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/RoundTripTests.java index 6863acc9ada..f5c31fe8f42 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/RoundTripTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/RoundTripTests.java @@ -69,8 +69,8 @@ public class RoundTripTests extends ESTestCase { } private void randomRequest(AbstractBulkIndexByScrollRequest request) { - request.getSource().indices("test"); - request.getSource().source().size(between(1, 1000)); + request.getSearchRequest().indices("test"); + request.getSearchRequest().source().size(between(1, 1000)); request.setSize(random().nextBoolean() ? between(1, Integer.MAX_VALUE) : -1); request.setAbortOnVersionConflict(random().nextBoolean()); request.setRefresh(rarely()); @@ -81,8 +81,8 @@ public class RoundTripTests extends ESTestCase { private void assertRequestEquals(AbstractBulkIndexByScrollRequest request, AbstractBulkIndexByScrollRequest tripped) { - assertArrayEquals(request.getSource().indices(), tripped.getSource().indices()); - assertEquals(request.getSource().source().size(), tripped.getSource().source().size()); + assertArrayEquals(request.getSearchRequest().indices(), tripped.getSearchRequest().indices()); + assertEquals(request.getSearchRequest().source().size(), tripped.getSearchRequest().source().size()); assertEquals(request.isAbortOnVersionConflict(), tripped.isAbortOnVersionConflict()); assertEquals(request.isRefresh(), tripped.isRefresh()); assertEquals(request.getTimeout(), tripped.getTimeout());