Skip to content

Commit

Permalink
Revert changes to SearchRequest and follow pipeline model
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Nied <[email protected]>
  • Loading branch information
peternied committed Feb 13, 2024
1 parent 6e9dffb commit cba189e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public static class Request extends SearchRequest {

private final String view;

public Request(final String view) {
super();
public Request(final String view, final SearchRequest searchRequest) {
super(searchRequest);
this.view = view;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ public class SearchRequest extends ActionRequest implements IndicesRequest.Repla

private static final long DEFAULT_ABSOLUTE_START_MILLIS = -1;

protected final String localClusterAlias;
protected final long absoluteStartMillis;
protected final boolean finalReduce;
private final String localClusterAlias;
private final long absoluteStartMillis;
private final boolean finalReduce;

private SearchType searchType = SearchType.DEFAULT;

protected String[] indices = Strings.EMPTY_ARRAY;
private String[] indices = Strings.EMPTY_ARRAY;

@Nullable
private String routing;
Expand Down Expand Up @@ -189,7 +189,7 @@ static SearchRequest subSearchRequest(
return new SearchRequest(originalSearchRequest, indices, clusterAlias, absoluteStartMillis, finalReduce);
}

protected SearchRequest(
private SearchRequest(
SearchRequest searchRequest,
String[] indices,
String localClusterAlias,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.opensearch.action.admin.indices.view.ListViewNamesAction;
import org.opensearch.action.admin.indices.view.SearchViewAction;
import org.opensearch.action.admin.indices.view.UpdateViewAction;
import org.opensearch.action.search.SearchRequest;
import org.opensearch.client.node.NodeClient;
import org.opensearch.common.ValidationException;
import org.opensearch.common.annotation.ExperimentalApi;
Expand Down Expand Up @@ -212,7 +213,7 @@ public String getName() {
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
final String viewId = request.param(VIEW_NAME);

final SearchViewAction.Request viewSearchRequest = new SearchViewAction.Request(viewId);
final SearchViewAction.Request viewSearchRequest = new SearchViewAction.Request(viewId, new SearchRequest());
final IntConsumer setSize = size -> viewSearchRequest.source().size(size);

request.withContentOrSourceParamParserOrNull(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void testValidateRequest() throws IOException {
}

public void testValidateRequestWithoutName() {
final SearchViewAction.Request request = new SearchViewAction.Request((String) null);
final SearchViewAction.Request request = new SearchViewAction.Request((String) null, new SearchRequest());
final ActionRequestValidationException e = request.validate();

MatcherAssert.assertThat(e.validationErrors().size(), equalTo(1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import org.opensearch.ResourceNotFoundException;
import org.opensearch.action.search.SearchAction;
import org.opensearch.action.search.SearchRequest;
import org.opensearch.client.node.NodeClient;
import org.opensearch.cluster.ClusterName;
import org.opensearch.cluster.ClusterState;
Expand Down Expand Up @@ -176,7 +177,7 @@ public void listViewNames_noViews() {
}

public void searchView() {
final var request = spy(new SearchViewAction.Request(randomAlphaOfLength(8)));
final var request = spy(new SearchViewAction.Request(randomAlphaOfLength(8), new SearchRequest()));
final var listener = mock(ActionListener.class);
setGetViewOrThrowExceptionToReturnTypicalView();

Expand Down

0 comments on commit cba189e

Please sign in to comment.