Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
Change class returned by search scroll to be search result.
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas abdi committed May 5, 2020
1 parent debfca8 commit 6fd0b61
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
11 changes: 8 additions & 3 deletions jest-common/src/main/java/io/searchbox/core/SearchScroll.java
Expand Up @@ -2,7 +2,9 @@

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Joiner;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import io.searchbox.action.AbstractAction;
import io.searchbox.action.AbstractMultiIndexActionBuilder;
import io.searchbox.action.GenericResultAbstractAction;
import io.searchbox.client.config.ElasticsearchVersion;
Expand All @@ -11,13 +13,11 @@
/**
* @author ferhat
*/
public class SearchScroll extends GenericResultAbstractAction {
public class SearchScroll extends AbstractAction<SearchResult> {
@VisibleForTesting
static final int MAX_SCROLL_ID_LENGTH = 1900;
private final String restMethodName;
public static final String SCROLL_ID = "scroll_id";
public static final String COMMA = ",";


protected SearchScroll(Builder builder) {
super(builder);
Expand All @@ -33,6 +33,11 @@ protected SearchScroll(Builder builder) {
}
}

@Override
public SearchResult createNewElasticSearchResult(String responseBody, int statusCode, String reasonPhrase, Gson gson) {
return createNewElasticSearchResult(new SearchResult(gson), responseBody, statusCode, reasonPhrase, gson);
}

@Override
protected String buildURI(ElasticsearchVersion elasticsearchVersion) {
return super.buildURI(elasticsearchVersion) + "/_search/scroll";
Expand Down
Expand Up @@ -46,7 +46,7 @@ public void searchWithValidQuery() throws IOException, JSONException {
.addSort(new Sort("code"))
.setParameter(Parameters.SCROLL, "5m")
.build();
JestResult result = client.execute(search);
SearchResult result = client.execute(search);
assertTrue(result.getErrorMessage(), result.isSucceeded());
JsonArray hits = result.getJsonObject().getAsJsonObject("hits").getAsJsonArray("hits");
assertEquals(
Expand Down Expand Up @@ -81,8 +81,8 @@ public void searchWithValidQuery() throws IOException, JSONException {

// clear a single scroll id
ClearScroll clearScroll = new ClearScroll.Builder().addScrollId(scrollId).build();
result = client.execute(clearScroll);
assertTrue(result.getErrorMessage(), result.isSucceeded());
JestResult clearResult = client.execute(clearScroll);
assertTrue(clearResult.getErrorMessage(), clearResult.isSucceeded());
}

@Test
Expand All @@ -103,7 +103,7 @@ public void clearScrollAll() throws IOException, JSONException {
.addSort(new Sort("code"))
.setParameter(Parameters.SCROLL, "5m")
.build();
JestResult result = client.execute(search);
SearchResult result = client.execute(search);
assertTrue(result.getErrorMessage(), result.isSucceeded());
JsonArray hits = result.getJsonObject().getAsJsonObject("hits").getAsJsonArray("hits");
assertEquals(
Expand Down Expand Up @@ -138,8 +138,8 @@ public void clearScrollAll() throws IOException, JSONException {

// clear all scroll ids
ClearScroll clearScroll = new ClearScroll.Builder().build();
result = client.execute(clearScroll);
assertTrue(result.getErrorMessage(), result.isSucceeded());
JestResult clearResult = client.execute(clearScroll);
assertTrue(clearResult.getErrorMessage(), clearResult.isSucceeded());
}

}

0 comments on commit 6fd0b61

Please sign in to comment.