Browse Source

Fix HLRC doc link for point in time API (#73874)

The PIT's docs in HLRC wasn't linked properly.
Nhat Nguyen 4 years ago
parent
commit
1211b9d5e4

+ 5 - 43
client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java

@@ -743,8 +743,8 @@ public class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
         openRequest.keepAlive(TimeValue.timeValueMinutes(30)); // <2>
         openRequest.keepAlive(TimeValue.timeValueMinutes(30)); // <2>
         OpenPointInTimeResponse openResponse = client.openPointInTime(openRequest, RequestOptions.DEFAULT);
         OpenPointInTimeResponse openResponse = client.openPointInTime(openRequest, RequestOptions.DEFAULT);
         String pitId = openResponse.getPointInTimeId(); // <3>
         String pitId = openResponse.getPointInTimeId(); // <3>
-        assertNotNull(pitId);
         // end::open-point-in-time
         // end::open-point-in-time
+        assertNotNull(pitId);
 
 
         // tag::search-point-in-time
         // tag::search-point-in-time
         SearchRequest searchRequest = new SearchRequest();
         SearchRequest searchRequest = new SearchRequest();
@@ -752,14 +752,15 @@ public class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
         pointInTimeBuilder.setKeepAlive("2m"); // <2>
         pointInTimeBuilder.setKeepAlive("2m"); // <2>
         searchRequest.source(new SearchSourceBuilder().pointInTimeBuilder(pointInTimeBuilder)); // <3>
         searchRequest.source(new SearchSourceBuilder().pointInTimeBuilder(pointInTimeBuilder)); // <3>
         SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
         SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
-        assertThat(searchResponse.pointInTimeId(), equalTo(pitId));
         // end::search-point-in-time
         // end::search-point-in-time
+        assertThat(searchResponse.pointInTimeId(), equalTo(pitId));
 
 
         // tag::close-point-in-time
         // tag::close-point-in-time
         ClosePointInTimeRequest closeRequest = new ClosePointInTimeRequest(pitId); // <1>
         ClosePointInTimeRequest closeRequest = new ClosePointInTimeRequest(pitId); // <1>
         ClearScrollResponse closeResponse = client.closePointInTime(closeRequest, RequestOptions.DEFAULT);
         ClearScrollResponse closeResponse = client.closePointInTime(closeRequest, RequestOptions.DEFAULT);
-        assertTrue(closeResponse.isSucceeded());
+        boolean succeeded = closeResponse.isSucceeded();
         // end::close-point-in-time
         // end::close-point-in-time
+        assertTrue(succeeded);
 
 
         // Open a point in time with optional arguments
         // Open a point in time with optional arguments
         {
         {
@@ -770,7 +771,7 @@ public class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
 
 
             // tag::open-point-in-time-routing
             // tag::open-point-in-time-routing
             openRequest.routing("routing"); // <1>
             openRequest.routing("routing"); // <1>
-            // end::explain-request-routing
+            // end::open-point-in-time-routing
 
 
             // tag::open-point-in-time-preference
             // tag::open-point-in-time-preference
             openRequest.preference("_local"); // <1>
             openRequest.preference("_local"); // <1>
@@ -782,45 +783,6 @@ public class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
         }
         }
     }
     }
 
 
-    public void testSearchAfterWithPointInTime() throws Exception {
-        RestHighLevelClient client = highLevelClient();
-        int numDocs = between(50, 100);
-        BulkRequest request = new BulkRequest();
-        for (int i = 0; i < numDocs; i++) {
-            request.add(new IndexRequest("posts").id(Integer.toString(i)).source(XContentType.JSON, "field", i));
-        }
-        request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
-        BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT);
-        assertSame(RestStatus.OK, bulkResponse.status());
-        assertFalse(bulkResponse.hasFailures());
-
-        // tag::search-after-with-point-in-time
-        OpenPointInTimeRequest openRequest = new OpenPointInTimeRequest("posts");
-        openRequest.keepAlive(TimeValue.timeValueMinutes(20));
-        String pitId = client.openPointInTime(openRequest, RequestOptions.DEFAULT).getPointInTimeId(); // <1>
-        assertNotNull(pitId);
-
-        SearchResponse searchResponse = null;
-        int totalHits = 0;
-        do {
-            SearchRequest searchRequest = new SearchRequest().source(new SearchSourceBuilder().sort("field").size(5)); // <2>
-            if (searchResponse != null) {
-                final SearchHit[] lastHits = searchResponse.getHits().getHits();
-                searchRequest.source().searchAfter(lastHits[lastHits.length - 1].getSortValues()); // <3>
-            }
-            searchRequest.source().pointInTimeBuilder(new PointInTimeBuilder(pitId)); // <4>
-            searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
-            assertThat(searchResponse.pointInTimeId(), equalTo(pitId));
-            totalHits += searchResponse.getHits().getHits().length;
-        } while (searchResponse.getHits().getHits().length > 0);
-
-        assertThat(totalHits, equalTo(numDocs));
-
-        ClearScrollResponse closeResponse = client.closePointInTime(new ClosePointInTimeRequest(pitId), RequestOptions.DEFAULT); // <5>
-        assertTrue(closeResponse.isSucceeded());
-        // end::search-after-with-point-in-time
-    }
-
     public void testSearchTemplateWithInlineScript() throws Exception {
     public void testSearchTemplateWithInlineScript() throws Exception {
         indexSearchTestData();
         indexSearchTestData();
         RestHighLevelClient client = highLevelClient();
         RestHighLevelClient client = highLevelClient();

+ 1 - 12
docs/java-rest/high-level/search/point-in-time.asciidoc

@@ -1,4 +1,4 @@
-[[java-rest-high-search-point-in-time]]
+[[java-rest-high-point-in-time]]
 
 
 === Open a point in time
 === Open a point in time
 
 
@@ -53,19 +53,8 @@ include-tagged::{doc-tests}/SearchDocumentationIT.java[search-point-in-time]
 A search request with a point in time does not accept these parameters:
 A search request with a point in time does not accept these parameters:
 `indices`, `indicesOptions` `routing`, `preference`, and `ccsMinimizeRoundtrips`.
 `indices`, `indicesOptions` `routing`, `preference`, and `ccsMinimizeRoundtrips`.
 
 
-==== Paginate search results with point in time
 A point in time can be used in search after requests to paginate search results.
 A point in time can be used in search after requests to paginate search results.
 
 
-["source","java",subs="attributes,callouts,macros"]
---------------------------------------------------
-include-tagged::{doc-tests}/SearchDocumentationIT.java[search-after-with-point-in-time]
---------------------------------------------------
-<1> Open a point in time that will be used in multiple search_after requests
-<2> Create a search request with the sort parameter
-<3> Set the search_after parameter using the sort values from the previous page
-<4> Pass a point in time to a search request
-<5> Close the point in time
-
 === Close point in time
 === Close point in time
 
 
 Point in time should be closed as soon as they are no longer used in search requests.
 Point in time should be closed as soon as they are no longer used in search requests.

+ 2 - 0
docs/java-rest/high-level/supported-apis.asciidoc

@@ -60,6 +60,7 @@ The Java High Level REST Client supports the following Search APIs:
 * <<{upid}-rank-eval>>
 * <<{upid}-rank-eval>>
 * <<{upid}-explain>>
 * <<{upid}-explain>>
 * <<{upid}-count>>
 * <<{upid}-count>>
+* <<{upid}-point-in-time>>
 
 
 include::search/search.asciidoc[]
 include::search/search.asciidoc[]
 include::search/scroll.asciidoc[]
 include::search/scroll.asciidoc[]
@@ -70,6 +71,7 @@ include::search/field-caps.asciidoc[]
 include::search/rank-eval.asciidoc[]
 include::search/rank-eval.asciidoc[]
 include::search/explain.asciidoc[]
 include::search/explain.asciidoc[]
 include::search/count.asciidoc[]
 include::search/count.asciidoc[]
+include::search/point-in-time.asciidoc[]
 
 
 [role="xpack"]
 [role="xpack"]
 == Async Search APIs
 == Async Search APIs