//组建SearchRequest SearchQuery searchQuery = new SearchQuery(); TermQuery termQuery = new TermQuery(); // 设置查询类型为TermQuery termQuery.setFieldName("docchannel"); // 设置要匹配的字段 termQuery.setTerm(ColumnValue.fromLong(52L)); // 设置要匹配的值 searchQuery.setQuery(termQuery); //document:tableName,indexName:document_index SearchRequest searchRequest = new SearchRequest("document", "document_index", searchQuery); SearchRequest.ColumnsToGet columnsToGet = new SearchRequest.ColumnsToGet(); //1. 返回某个字段,就设置某个字段 Listlist = new ArrayList<>(); list.add("docchannel"); columnsToGet.setColumns(list); //2.返回全部字段 //columnsToGet.setReturnAll(true); // 设置返回所有列 searchRequest.setColumnsToGet(columnsToGet); endPoint: ***** //ots服务器连接地址 accessKeyId: '*****' accessKeySecret: '******' instanceName: **** SyncClient client = new SyncClient(endPoint, accessKeyId, accessKeySecret, instanceName, clientConfiguration); SearchResponse resp = client.search(searchRequest); List rows = resp.getRows(); while(resp.getNextToken() != null){ //把token设置到下一次请求中 searchRequest.getSearchQuery().setToken(resp.getNextToken()); resp = client.search(searchRequest); if (!resp.isAllSuccess()){ throw new RuntimeException("not all success"); } rows.addAll(resp.getRows()); } System.out.println("RowSize:" + rows.size());
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)