diff --git a/.idea/runConfigurations/Debug_OpenSearch.xml b/.idea/runConfigurations/Debug_OpenSearch.xml
index 0d8bf59823acf..c18046f873477 100644
--- a/.idea/runConfigurations/Debug_OpenSearch.xml
+++ b/.idea/runConfigurations/Debug_OpenSearch.xml
@@ -6,6 +6,10 @@
+
+
+
+
-
+
\ No newline at end of file
diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/RequestConverters.java b/client/rest-high-level/src/main/java/org/opensearch/client/RequestConverters.java
index 88e3a3a904830..70a18ff85374f 100644
--- a/client/rest-high-level/src/main/java/org/opensearch/client/RequestConverters.java
+++ b/client/rest-high-level/src/main/java/org/opensearch/client/RequestConverters.java
@@ -53,12 +53,7 @@
import org.opensearch.action.get.GetRequest;
import org.opensearch.action.get.MultiGetRequest;
import org.opensearch.action.index.IndexRequest;
-import org.opensearch.action.search.ClearScrollRequest;
-import org.opensearch.action.search.CreatePitRequest;
-import org.opensearch.action.search.DeletePitRequest;
-import org.opensearch.action.search.MultiSearchRequest;
-import org.opensearch.action.search.SearchRequest;
-import org.opensearch.action.search.SearchScrollRequest;
+import org.opensearch.action.search.*;
import org.opensearch.action.support.ActiveShardCount;
import org.opensearch.action.support.IndicesOptions;
import org.opensearch.action.support.WriteRequest;
@@ -502,6 +497,11 @@ static Request getAllPits() {
return new Request(HttpGet.METHOD_NAME, "/_search/point_in_time/_all");
}
+ static Request updatePit(UpdatePitRequest updatePitRequest) throws IOException {
+ Request request = new Request(HttpDelete.METHOD_NAME, "/_search/point_in_time");
+ request.setEntity(createEntity(updatePitRequest, REQUEST_BODY_CONTENT_TYPE));
+ return request;
+ }
static Request multiSearch(MultiSearchRequest multiSearchRequest) throws IOException {
Request request = new Request(HttpPost.METHOD_NAME, "/_msearch");
diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/RestHighLevelClient.java b/client/rest-high-level/src/main/java/org/opensearch/client/RestHighLevelClient.java
index 27f13fc3c00c4..4852b2138ae1a 100644
--- a/client/rest-high-level/src/main/java/org/opensearch/client/RestHighLevelClient.java
+++ b/client/rest-high-level/src/main/java/org/opensearch/client/RestHighLevelClient.java
@@ -57,18 +57,7 @@
import org.opensearch.action.get.MultiGetResponse;
import org.opensearch.action.index.IndexRequest;
import org.opensearch.action.index.IndexResponse;
-import org.opensearch.action.search.ClearScrollRequest;
-import org.opensearch.action.search.ClearScrollResponse;
-import org.opensearch.action.search.CreatePitRequest;
-import org.opensearch.action.search.CreatePitResponse;
-import org.opensearch.action.search.DeletePitRequest;
-import org.opensearch.action.search.DeletePitResponse;
-import org.opensearch.action.search.GetAllPitNodesResponse;
-import org.opensearch.action.search.MultiSearchRequest;
-import org.opensearch.action.search.MultiSearchResponse;
-import org.opensearch.action.search.SearchRequest;
-import org.opensearch.action.search.SearchResponse;
-import org.opensearch.action.search.SearchScrollRequest;
+import org.opensearch.action.search.*;
import org.opensearch.action.support.master.AcknowledgedResponse;
import org.opensearch.action.update.UpdateRequest;
import org.opensearch.action.update.UpdateResponse;
@@ -1403,6 +1392,16 @@ public final Cancellable getAllPitsAsync(RequestOptions options, ActionListener<
);
}
+ public final UpdatePitResponse updatePit(UpdatePitRequest updatePitRequest, RequestOptions options) throws IOException {
+ return performRequestAndParseEntity(
+ updatePitRequest,
+ RequestConverters::updatePit,
+ options,
+ UpdatePitResponse::fromXContent,
+ emptySet()
+ );
+ }
+
/**
* Clears one or more scroll ids using the Clear Scroll API.
*
diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/PitIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/PitIT.java
index 1f10deb400ecc..c2b48b692c61e 100644
--- a/client/rest-high-level/src/test/java/org/opensearch/client/PitIT.java
+++ b/client/rest-high-level/src/test/java/org/opensearch/client/PitIT.java
@@ -32,7 +32,7 @@
* Tests point in time API with rest high level client
*/
public class PitIT extends OpenSearchRestHighLevelClientTestCase {
-
+//--this is is PITIT
@Before
public void indexDocuments() throws IOException {
Request doc1 = new Request(HttpPut.METHOD_NAME, "/index/_doc/1");
diff --git a/server/src/main/java/org/opensearch/action/search/UpdatePitAction.java b/server/src/main/java/org/opensearch/action/search/UpdatePitAction.java
new file mode 100644
index 0000000000000..01dff89def026
--- /dev/null
+++ b/server/src/main/java/org/opensearch/action/search/UpdatePitAction.java
@@ -0,0 +1,20 @@
+/*
+ * 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.search;
+
+import org.opensearch.action.ActionType;
+
+public class UpdatePitAction extends ActionType {
+ public static final UpdatePitAction INSTANCE = new UpdatePitAction();
+ public static final String NAME = "indices:data/read/point_in_time/update";
+
+ private UpdatePitAction(){
+ super(NAME, UpdatePitResponse::new);
+ }
+}
diff --git a/server/src/main/java/org/opensearch/action/search/UpdatePitInfo.java b/server/src/main/java/org/opensearch/action/search/UpdatePitInfo.java
new file mode 100644
index 0000000000000..0a71ed0564dd5
--- /dev/null
+++ b/server/src/main/java/org/opensearch/action/search/UpdatePitInfo.java
@@ -0,0 +1,75 @@
+/*
+ * 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.search;
+
+import org.opensearch.common.ParseField;
+import org.opensearch.common.io.stream.StreamInput;
+import org.opensearch.common.io.stream.StreamOutput;
+import org.opensearch.common.io.stream.Writeable;
+import org.opensearch.common.xcontent.ConstructingObjectParser;
+import org.opensearch.common.xcontent.ToXContent;
+import org.opensearch.common.xcontent.XContentBuilder;
+import org.opensearch.transport.TransportResponse;
+
+import java.io.IOException;
+
+import static org.opensearch.common.xcontent.ConstructingObjectParser.constructorArg;
+
+public class UpdatePitInfo extends TransportResponse implements Writeable, ToXContent {
+ private final boolean successful;
+ private final String pitId;
+
+ public UpdatePitInfo(boolean successful, String pitId){
+ this.successful = successful;
+ this.pitId = pitId;
+ }
+
+ public UpdatePitInfo(StreamInput in) throws IOException{
+ successful = in.readBoolean();
+ pitId = in.readString();
+ }
+
+ public boolean isSuccessful(){
+ return successful;
+ }
+
+ public String getPitId(){
+ return pitId;
+ }
+
+ @Override
+ public void writeTo(StreamOutput out) throws IOException {
+ out.writeBoolean(successful);
+ out.writeString(pitId);
+ }
+
+ static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>(
+ "update_pit_info",
+ true,
+ args -> new UpdatePitInfo((boolean) args[0], (String) args[1])
+ );
+
+ static {
+ PARSER.declareBoolean(constructorArg(), new ParseField("successful"));
+ PARSER.declareString(constructorArg(), new ParseField("pit_id"));
+ }
+
+ private static final ParseField SUCCESSFUL = new ParseField("successful");
+ private static final ParseField PIT_ID = new ParseField("pit_id");
+
+ @Override
+ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
+ builder.startObject();
+ builder.field(SUCCESSFUL.getPreferredName(), successful);
+ builder.field(PIT_ID.getPreferredName(), pitId);
+ builder.endObject();
+ return builder;
+ }
+}
+
diff --git a/server/src/main/java/org/opensearch/action/search/UpdatePitRequest.java b/server/src/main/java/org/opensearch/action/search/UpdatePitRequest.java
new file mode 100644
index 0000000000000..97917681b5222
--- /dev/null
+++ b/server/src/main/java/org/opensearch/action/search/UpdatePitRequest.java
@@ -0,0 +1,77 @@
+/*
+ * 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.search;
+
+import org.opensearch.action.ActionRequest;
+import org.opensearch.action.ActionRequestValidationException;
+import org.opensearch.common.io.stream.StreamInput;
+import org.opensearch.common.unit.TimeValue;
+import org.opensearch.common.xcontent.ToXContent;
+import org.opensearch.common.xcontent.ToXContentObject;
+import org.opensearch.common.xcontent.XContentBuilder;
+import org.opensearch.common.xcontent.XContentParser;
+
+import java.io.IOException;
+
+import static org.opensearch.action.ValidateActions.addValidationError;
+
+public class UpdatePitRequest extends ActionRequest implements ToXContentObject {
+
+ private String pit_id;
+ private TimeValue keepAlive;
+
+ public UpdatePitRequest(String pit_id){
+ this.keepAlive = null;
+ this.pit_id = pit_id;
+ }
+
+ public UpdatePitRequest(StreamInput in) throws IOException {
+ super(in);
+ pit_id = in.readString();
+ keepAlive = in.readTimeValue();
+ }
+
+ public UpdatePitRequest() {}
+
+ @Override
+ public ActionRequestValidationException validate() {
+ ActionRequestValidationException validationException = null;
+ if (keepAlive == null) {
+ validationException = addValidationError("keep alive not specified", validationException);
+ }
+ return validationException;
+ }
+
+ @Override
+ public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException {
+ builder.field("keep_alive", keepAlive);
+ builder.field("pit_id", pit_id);
+ return builder;
+ }
+
+ public void fromXContent(XContentParser parser) throws IOException {
+ if(parser.nextToken() != XContentParser.Token.START_OBJECT){
+ throw new IllegalArgumentException("Malformed content, must start with an object");
+ } else {
+ XContentParser.Token token;
+ String currentFieldName = null;
+ while((token = parser.nextToken()) != XContentParser.Token.END_OBJECT){
+ if (token == XContentParser.Token.FIELD_NAME){
+ currentFieldName = parser.currentName();
+ } else if("keep_alive".equals(currentFieldName)){
+ if(token.isValue() == false){
+ throw new IllegalArgumentException("keep_alive should only contain a time value");
+ }
+ keepAlive = TimeValue.parseTimeValue(parser.text(),"keep_alive");
+ }
+
+ }
+ }
+ }
+}
diff --git a/server/src/main/java/org/opensearch/action/search/UpdatePitResponse.java b/server/src/main/java/org/opensearch/action/search/UpdatePitResponse.java
new file mode 100644
index 0000000000000..13af5adf9bd3c
--- /dev/null
+++ b/server/src/main/java/org/opensearch/action/search/UpdatePitResponse.java
@@ -0,0 +1,149 @@
+/*
+ * 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.search;
+
+import org.opensearch.action.ActionResponse;
+import org.opensearch.common.ParseField;
+import org.opensearch.common.io.stream.StreamInput;
+import org.opensearch.common.io.stream.StreamOutput;
+import org.opensearch.common.xcontent.StatusToXContentObject;
+import org.opensearch.common.xcontent.XContentBuilder;
+import org.opensearch.common.xcontent.XContentParser;
+import org.opensearch.rest.RestStatus;
+import org.opensearch.rest.action.RestActions;
+
+import java.io.IOException;
+
+import static org.opensearch.common.xcontent.XContentParserUtils.ensureExpectedToken;
+import static org.opensearch.rest.RestStatus.OK;
+
+public class UpdatePitResponse extends ActionResponse implements StatusToXContentObject {
+
+ private static final ParseField ID = new ParseField("pit_id");
+ private static final ParseField CREATION_TIME = new ParseField("creation_time");
+ private static final ParseField EXPIRY_TIME = new ParseField("expiry_time");
+
+ private final String id;
+ private final int totalShards;
+ private final int successfulShards;
+ private final int failedShards;
+ private final int skippedShards;
+ private final ShardSearchFailure[] shardFailures;
+
+ private final long creationTime;
+ private final long expiryTime;
+ public UpdatePitResponse(StreamInput in) throws IOException {
+ super(in);
+ id = in.readString();
+ totalShards = in.readVInt();
+ successfulShards = in.readVInt();
+ failedShards = in.readVInt();
+ skippedShards = in.readVInt();
+ creationTime = in.readLong();
+ expiryTime = in.readLong();
+ int size = in.readVInt();
+ if(size==0){
+ shardFailures = ShardSearchFailure.EMPTY_ARRAY;
+ } else {
+ shardFailures = new ShardSearchFailure[size];
+ for (int i=0; i < shardFailures.length; i++){
+ shardFailures[i] = ShardSearchFailure.readShardSearchFailure(in);
+ }
+ }
+ }
+
+ public UpdatePitResponse(
+ String id,
+ long creationTime,
+ long expiryTime,
+ int totalShards,
+ int successfulShards,
+ int skippedShards,
+ int failedShards,
+ ShardSearchFailure[] shardFailures
+ ) {
+ this.id = id;
+ this.creationTime = creationTime;
+ this.expiryTime = expiryTime;
+ this.totalShards = totalShards;
+ this.successfulShards = successfulShards;
+ this.skippedShards = skippedShards;
+ this.failedShards = failedShards;
+ this.shardFailures = shardFailures;
+ }
+
+ public static CreatePitResponse fromXContent(XContentParser parser) throws IOException{
+ ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.nextToken(), parser);
+ parser.nextToken();
+ return innerFromXContent(parser);
+ }
+
+ public static CreatePitResponse innerFromXContent(XContentParser parser) throws IOException {
+
+ }
+ @Override
+ public void writeTo(StreamOutput out) throws IOException{
+ out.writeString(id);
+ out.writeVInt(totalShards);
+ out.writeVInt(successfulShards);
+ out.writeVInt(failedShards);
+ out.writeVInt(skippedShards);
+ out.writeLong(creationTime);
+ out.writeLong(expiryTime);
+ out.writeVInt(shardFailures.length);
+ for (ShardSearchFailure shardSearchFailure : shardFailures) {
+ shardSearchFailure.writeTo(out);
+ }
+ }
+
+ @Override
+ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
+ builder.startObject();
+ builder.field(ID.getPreferredName(), id);
+ RestActions.buildBroadcastShardsHeader(
+ builder,
+ params,
+ getTotalShards(),
+ getSuccessfulShards(),
+ getSkippedShards(),
+ getFailedShards(),
+ getShardFailures()
+ );
+ builder.field(CREATION_TIME.getPreferredName(), creationTime);
+ builder.field(EXPIRY_TIME.getPreferredName(), expiryTime);
+ builder.endObject();
+ return builder;
+ }
+
+ public int getTotalShards(){
+ return totalShards;
+ }
+
+ public int getSuccessfulShards(){
+ return successfulShards;
+ }
+
+ public int getFailedShards(){
+ return shardFailures.length;
+ }
+
+ public ShardSearchFailure[] getShardFailures() {
+ return this.shardFailures;
+ }
+
+ public int getSkippedShards(){
+ return skippedShards;
+ }
+
+ @Override
+ public RestStatus status() {
+ return RestStatus.status(successfulShards, totalShards, shardFailures);
+ }
+}
+//
diff --git a/server/src/main/java/org/opensearch/client/support/AbstractClient.java b/server/src/main/java/org/opensearch/client/support/AbstractClient.java
index 828ca5f8083ee..2927f59444b32 100644
--- a/server/src/main/java/org/opensearch/client/support/AbstractClient.java
+++ b/server/src/main/java/org/opensearch/client/support/AbstractClient.java
@@ -349,30 +349,7 @@
import org.opensearch.action.ingest.SimulatePipelineRequest;
import org.opensearch.action.ingest.SimulatePipelineRequestBuilder;
import org.opensearch.action.ingest.SimulatePipelineResponse;
-import org.opensearch.action.search.ClearScrollAction;
-import org.opensearch.action.search.ClearScrollRequest;
-import org.opensearch.action.search.ClearScrollRequestBuilder;
-import org.opensearch.action.search.ClearScrollResponse;
-import org.opensearch.action.search.CreatePitAction;
-import org.opensearch.action.search.CreatePitRequest;
-import org.opensearch.action.search.CreatePitResponse;
-import org.opensearch.action.search.DeletePitAction;
-import org.opensearch.action.search.DeletePitRequest;
-import org.opensearch.action.search.DeletePitResponse;
-import org.opensearch.action.search.GetAllPitNodesRequest;
-import org.opensearch.action.search.GetAllPitNodesResponse;
-import org.opensearch.action.search.MultiSearchAction;
-import org.opensearch.action.search.MultiSearchRequest;
-import org.opensearch.action.search.MultiSearchRequestBuilder;
-import org.opensearch.action.search.MultiSearchResponse;
-import org.opensearch.action.search.GetAllPitsAction;
-import org.opensearch.action.search.SearchAction;
-import org.opensearch.action.search.SearchRequest;
-import org.opensearch.action.search.SearchRequestBuilder;
-import org.opensearch.action.search.SearchResponse;
-import org.opensearch.action.search.SearchScrollAction;
-import org.opensearch.action.search.SearchScrollRequest;
-import org.opensearch.action.search.SearchScrollRequestBuilder;
+import org.opensearch.action.search.*;
import org.opensearch.action.support.PlainActionFuture;
import org.opensearch.action.support.master.AcknowledgedResponse;
import org.opensearch.action.termvectors.MultiTermVectorsAction;
@@ -627,6 +604,11 @@ public void getAllPits(final GetAllPitNodesRequest getAllPitNodesRequest, final
execute(GetAllPitsAction.INSTANCE, getAllPitNodesRequest, listener);
}
+ @Override
+ public void updatePit(final UpdatePitRequest updatePitRequest, final ActionListener listener){
+ execute(UpdatePitAction.INSTANCE, updatePitRequest, listener);
+ }
+
@Override
public void pitSegments(final PitSegmentsRequest request, final ActionListener listener) {
execute(PitSegmentsAction.INSTANCE, request, listener);
diff --git a/server/src/main/java/org/opensearch/rest/action/search/RestUpdatePitAction.java b/server/src/main/java/org/opensearch/rest/action/search/RestUpdatePitAction.java
new file mode 100644
index 0000000000000..2f6a87243b2d5
--- /dev/null
+++ b/server/src/main/java/org/opensearch/rest/action/search/RestUpdatePitAction.java
@@ -0,0 +1,53 @@
+/*
+ * 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.rest.action.search;
+
+import org.opensearch.action.search.UpdatePitRequest;
+import org.opensearch.client.node.NodeClient;
+import org.opensearch.common.unit.TimeValue;
+import org.opensearch.rest.BaseRestHandler;
+import org.opensearch.rest.RestRequest;
+import org.opensearch.rest.action.RestStatusToXContentListener;
+
+import java.io.IOException;
+import java.util.List;
+
+import static java.util.Arrays.asList;
+import static java.util.Collections.unmodifiableList;
+import static org.opensearch.rest.RestRequest.Method.POST;
+
+public class RestUpdatePitAction extends BaseRestHandler {
+
+ @Override
+ public String getName(){
+ return "update_pit_action";
+ }
+
+ public RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
+ String pit_id = request.param("pit_id");
+ UpdatePitRequest updatePitRequest = new UpdatePitRequest(pit_id);
+
+ request.withContentOrSourceParamParserOrNull((xContentParser -> {
+ if(xContentParser!=null){
+ try{
+ updatePitRequest.fromXContent(xContentParser);
+ } catch (IOException e) {
+ throw new IllegalArgumentException("Failed to parse request body", e);
+ }
+ }
+ }));
+
+ return channel -> client.updatePit(updatePitRequest, new RestStatusToXContentListener<>(channel));
+ }
+
+ @Override
+ public List routes() {
+ return unmodifiableList(asList(new Route(POST, "/_search/point_in_time/{pit_id}")));
+ }
+}