import io.searchbox.client.JestResult; //导入方法依赖的package包/类
/**
* Private method to handle scrolling through the results from the search request and adding them to a business object definition entity list.
*
* @param searchRequestBuilder the the search request to scroll through
* @param indexName the index name
* @return list of business object definition entities
*/
private List scrollSearchResultsIntoBusinessObjectDefinitionDto(
final SearchRequestBuilder searchRequestBuilder, String indexName)
{
// Retrieve the search response
final Search.Builder searchBuilder = new Search.Builder(searchRequestBuilder.toString()).addIndex(indexName);
searchBuilder.setParameter(Parameters.SIZE, ELASTIC_SEARCH_SCROLL_PAGE_SIZE);
searchBuilder.setParameter(Parameters.SCROLL, new TimeValue(ELASTIC_SEARCH_SCROLL_KEEP_ALIVE_TIME).toString());
JestResult jestResult = jestClientHelper.searchExecute(searchBuilder.build());
List businessObjectDefinitionIndexSearchResponseDtoList = new ArrayList<>();
List resultList =
jestResult.getSourceAsObjectList(BusinessObjectDefinitionIndexSearchResponseDto.class);
while (resultList.size() != 0)
{
businessObjectDefinitionIndexSearchResponseDtoList.addAll(resultList);
String scrollId = jestResult.getJsonObject().get(SCROLL_ID).getAsString();
SearchScroll scroll = new SearchScroll.Builder(scrollId, new TimeValue(ELASTIC_SEARCH_SCROLL_KEEP_ALIVE_TIME).toString()).build();
jestResult = jestClientHelper.searchScrollExecute(scroll);
resultList = jestResult.getSourceAsObjectList(BusinessObjectDefinitionIndexSearchResponseDto.class);
}
return businessObjectDefinitionIndexSearchResponseDtoList;
}