1.创建es对象
@Autowired
@Lazy
private ElasticsearchRestTemplate restTemplate;
2.赋值es对象
MaterialIndex materialIndex=new MaterialIndex();
BeanUtil.copyProperties(material,materialIndex);
materialIndex.setMaterialId(material.getId());
materialIndex.setMaterialNo(material.getMaterialNo());
materialIndex.setMaterialName(material.getName());
materialIndex.setViewCount(0);
materialIndex.setUsedCount(0);
materialIndex.setCollectionCount(0);
materialIndex.setOrderCount(0);
materialIndex.setMaterialSize(Integer.valueOf(qrFile.getFileSize().toString()));
materialIndex.setMaterialWidth(qrFile.getImgWidth());
materialIndex.setMaterialHeight(qrFile.getImgHeight());
materialIndex.setMaterialType(qrFile.getFileType());
materialIndex.setMaterialUrl(qrFile.getUrl());
materialIndex.setAuthorId(material.getUserId());
materialIndex.setAuthorImage(qrMember.getFace());
materialIndex.setAuthorName(qrMember.getUsername());
materialIndex.setCollectionStatus(1);
materialIndex.setDeleteFlag(false);
materialIndex.setCreateTime(material.getCreateTime().toString());
MaterialIndex save = elasticsearchRestTemplate.save(materialIndex);