栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

关于 ElasticsearchRestTemplate 的插入操作

关于 ElasticsearchRestTemplate 的插入操作

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());

            //添加到es中
            MaterialIndex save = elasticsearchRestTemplate.save(materialIndex);

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/699410.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号