| | |
| | | } |
| | | // 2. 多线程查询视频数据,构建文档对象 |
| | | Long totalVideo = new LambdaQueryChainWrapper<>(videoMapper) |
| | | .eq(Video::getStatus, VideoStatusEnum.PUBLISHED.getValue()) |
| | | .count(); |
| | | int totalThreads = (int) Math.ceil((double) totalVideo / 200); // 计算需要多少个线程 |
| | | CountDownLatch latch = new CountDownLatch(totalThreads); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void addOrUpdateDocument(String indexName, String id, Object data) { |
| | | indexName = this.getIndexFullName(indexName); |
| | | IndexRequest request = new IndexRequest(indexName); |
| | | request.id(id).source(data); |
| | | try { |
| | | client.index(request, RequestOptions.DEFAULT); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException("es文档添加/修改失败", e); |
| | | } |
| | | public void addOrUpdateDocument(Object data) { |
| | | VideoIndex videoIndex = (VideoIndex) data; |
| | | esVideoIndexRepository.save(videoIndex); |
| | | // indexName = this.getIndexFullName(indexName); |
| | | // IndexRequest request = new IndexRequest(indexName); |
| | | // request.id(id).source(data); |
| | | // try { |
| | | // client.index(request, RequestOptions.DEFAULT); |
| | | // } catch (IOException e) { |
| | | // throw new RuntimeException("es文档添加/修改失败", e); |
| | | // } |
| | | } |
| | | |
| | | @Override |