forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'createpit' of github.com:bharath-techie/OpenSearch into…
… deletepit
- Loading branch information
Showing
25 changed files
with
589 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
client/rest-high-level/src/test/java/org/opensearch/client/PitIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* 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.client; | ||
|
||
import org.apache.http.client.methods.HttpPost; | ||
import org.apache.http.client.methods.HttpPut; | ||
import org.junit.Before; | ||
import org.opensearch.action.search.CreatePitRequest; | ||
import org.opensearch.action.search.CreatePitResponse; | ||
import org.opensearch.common.unit.TimeValue; | ||
|
||
import java.io.IOException; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
/** | ||
* Tests point in time API with rest high level client | ||
*/ | ||
public class PitIT extends OpenSearchRestHighLevelClientTestCase { | ||
|
||
@Before | ||
public void indexDocuments() throws IOException { | ||
{ | ||
Request doc1 = new Request(HttpPut.METHOD_NAME, "/index/_doc/1"); | ||
doc1.setJsonEntity("{\"type\":\"type1\", \"id\":1, \"num\":10, \"num2\":50}"); | ||
client().performRequest(doc1); | ||
Request doc2 = new Request(HttpPut.METHOD_NAME, "/index/_doc/2"); | ||
doc2.setJsonEntity("{\"type\":\"type1\", \"id\":2, \"num\":20, \"num2\":40}"); | ||
client().performRequest(doc2); | ||
Request doc3 = new Request(HttpPut.METHOD_NAME, "/index/_doc/3"); | ||
doc3.setJsonEntity("{\"type\":\"type1\", \"id\":3, \"num\":50, \"num2\":35}"); | ||
client().performRequest(doc3); | ||
Request doc4 = new Request(HttpPut.METHOD_NAME, "/index/_doc/4"); | ||
doc4.setJsonEntity("{\"type\":\"type2\", \"id\":4, \"num\":100, \"num2\":10}"); | ||
client().performRequest(doc4); | ||
Request doc5 = new Request(HttpPut.METHOD_NAME, "/index/_doc/5"); | ||
doc5.setJsonEntity("{\"type\":\"type2\", \"id\":5, \"num\":100, \"num2\":10}"); | ||
client().performRequest(doc5); | ||
} | ||
|
||
client().performRequest(new Request(HttpPost.METHOD_NAME, "/_refresh")); | ||
} | ||
|
||
public void testCreatePit() throws IOException { | ||
CreatePitRequest pitRequest = new CreatePitRequest(new TimeValue(1, TimeUnit.DAYS), true, "index"); | ||
CreatePitResponse pitResponse = execute(pitRequest, highLevelClient()::createPit, highLevelClient()::createPitAsync); | ||
assertTrue(pitResponse.getId() != null); | ||
assertEquals(1, pitResponse.getTotalShards()); | ||
assertEquals(1, pitResponse.getSuccessfulShards()); | ||
assertEquals(0, pitResponse.getFailedShards()); | ||
assertEquals(0, pitResponse.getSkippedShards()); | ||
} | ||
/** | ||
* Todo: add deletion logic and test cluster settings | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
rest-api-spec/src/main/resources/rest-api-spec/api/create_pit.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"create_pit":{ | ||
"documentation":{ | ||
"url":"https://opensearch.org/docs/latest/opensearch/rest-api/point_in_time/", | ||
"description":"Creates point in time context." | ||
}, | ||
"stability":"stable", | ||
"url":{ | ||
"paths":[ | ||
{ | ||
"path":"/{index}/_search/point_in_time", | ||
"methods":[ | ||
"POST" | ||
], | ||
"parts":{ | ||
"index":{ | ||
"type":"list", | ||
"description":"A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"params":{ | ||
"allow_partial_pit_creation":{ | ||
"type":"boolean", | ||
"description":"Allow if point in time can be created with partial failures" | ||
}, | ||
"keep_alive":{ | ||
"type":"string", | ||
"description":"Specify the keep alive for point in time" | ||
}, | ||
"preference":{ | ||
"type":"string", | ||
"description":"Specify the node or shard the operation should be performed on (default: random)" | ||
}, | ||
"routing":{ | ||
"type":"list", | ||
"description":"A comma-separated list of specific routing values" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.