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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Decouple the init of Crypto Plugin and KeyProvider in CryptoRegistry ([18270](https://github.com/opensearch-project/OpenSearch/pull18270)))

### Changed
- Create generic DocRequest to better categorize ActionRequests ([#18269](https://github.com/opensearch-project/OpenSearch/pull/18269)))

### Dependencies
- Bump `com.google.code.gson:gson` from 2.12.1 to 2.13.1 ([#17923](https://github.com/opensearch-project/OpenSearch/pull/17923), [#18266](https://github.com/opensearch-project/OpenSearch/pull/18266))
Expand Down
31 changes: 31 additions & 0 deletions server/src/main/java/org/opensearch/action/DocRequest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.action;

import org.opensearch.common.annotation.PublicApi;

/**
* Generic interface to group ActionRequest, which perform actions on a single document
*
* @opensearch.api
*/
@PublicApi(since = "3.1.0")
public interface DocRequest {
/**
* Get the index that this request operates on
* @return the index
*/
String index();

/**
* Get the id of the document for this request
* @return the id
*/
String id();
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface DocWriteRequest<T> extends IndicesRequest, Accountable {
public interface DocWriteRequest<T> extends IndicesRequest, DocRequest, Accountable {

// Flag set for disallowing index auto creation for an individual write request.
String REQUIRE_ALIAS = "require_alias";
Expand All @@ -70,18 +70,6 @@ public interface DocWriteRequest<T> extends IndicesRequest, Accountable {
*/
T index(String index);

/**
* Get the index that this request operates on
* @return the index
*/
String index();

/**
* Get the id of the document for this request
* @return the id
*/
String id();

/**
* Get the options for this request
* @return the indices options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import org.opensearch.Version;
import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.action.DocRequest;
import org.opensearch.action.RealtimeRequest;
import org.opensearch.action.ValidateActions;
import org.opensearch.action.support.single.shard.SingleShardRequest;
Expand All @@ -49,6 +50,7 @@
import org.opensearch.transport.client.Requests;

import java.io.IOException;
import java.util.Objects;

import static org.opensearch.action.ValidateActions.addValidationError;

Expand All @@ -66,7 +68,7 @@
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public class GetRequest extends SingleShardRequest<GetRequest> implements RealtimeRequest {
public class GetRequest extends SingleShardRequest<GetRequest> implements RealtimeRequest, DocRequest {

private String id;
private String routing;
Expand Down Expand Up @@ -163,6 +165,12 @@ public GetRequest preference(String preference) {
return this;
}

@Override
public String index() {
return Objects.requireNonNull(super.index());
}

@Override
public String id() {
return id;
}
Expand Down
Loading