1.实体类
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/498bf4814f356c4429cf2f6773f62468.png)
2.插入数据
//1.实体类封装
AbnormalAccountEntity entity=new AbnormalAccountEntity();
entity.setId(UUID.randomUUID().toString().substring(0,12));
entity.setMainAcctId(UUID.randomUUID().toString().substring(0,12));
entity.setApprMainAcctName(UUID.randomUUID().toString().substring(0,12));
entity.setApprPersonName(UUID.randomUUID().toString().substring(0,12));
entity.setCheckTime("2020-07-24");
entity.setCreateTime("2020-07-24");
entity.setNumber(70);
//2.构建批量插入
List<IndexQuery> queries = new ArrayList<>();
//构建插入数据
IndexQuery indexQuery = new IndexQuery();
//设置ID,如果id相同会覆盖之前的数据
indexQuery.setId(entity.getId());
//插入的实体类
indexQuery.setObject(entity);
//索引
indexQuery.setIndexName("abnormal_number_account");
//类型
indexQuery.setType("doce");
//上面的那几步也可以使用IndexQueryBuilder来构建
//IndexQuery index = new IndexQueryBuilder().withId(person.getId() + "").withObject(person).build();
//3.添加到queries
queries.add(indexQuery);
//4.添加数据
elasticsearchTemplate.bulkIndex(queries);
queries.clear();