参考demo文档https://help.aliyun.com/document_detail/52361.html?spm=a2c4g.11186623.2.17.39f93c14HisGbR 第一次调用接口返回成功,并获取了scroll_id 第二次传递scroll_id,执行后返回错误"code":6019和"code":6008
@GetMapping("topic/scroll")
public String scroll(@RequestParam(value = "scroll_id", required = false) String scroll_id) throws OpenSearchClientException, OpenSearchException {
Config config = new Config(Lists.newArrayList(appName));
//设置每页为5条记录
config.setHits(1);
config.setSearchFormat(SearchFormat.FULLJSON);
SearchParams searchParams = new SearchParams(config);
//searchParams.setQuery("default_topic:'活动'");
DeepPaging deep =new DeepPaging();
//添加DeepPaging对象参数
searchParams.setDeepPaging(deep);
SearchParamsBuilder paramsBuilder = SearchParamsBuilder.create(searchParams);
SearchResult searchResult;
String result = null;
JSONObject obj = null;
//第一次执行不返回数据,主要返回scroll_id值,第二次调用查询时设置scroll_id
if (StringUtils.isEmpty(scroll_id)) {
searchResult = searcherClient.execute(paramsBuilder);
result = searchResult.getResult();
obj = new JSONObject(result);
deep.setScrollId(new JSONObject(obj.get("result").toString()).get("scroll_id").toString());
searchResult = searcherClient.execute(paramsBuilder);
result = searchResult.getResult();
obj = new JSONObject(result);
return obj.get("result").toString();
}
deep.setScrollId(scroll_id);
searchResult = searcherClient.execute(paramsBuilder);
result = searchResult.getResult();
log.info(result);
obj = new JSONObject(result);
return obj.get("result").toString();
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。