|
|
@ -9,9 +9,11 @@ import com.ruoyi.api.domain.ESDao; |
|
|
import com.ruoyi.api.domain.ZhyDocApi; |
|
|
import com.ruoyi.api.domain.ZhyDocApi; |
|
|
import com.ruoyi.api.mapper.ZhyDocApiMapper; |
|
|
import com.ruoyi.api.mapper.ZhyDocApiMapper; |
|
|
import com.ruoyi.system.domain.ZhyArticle; |
|
|
import com.ruoyi.system.domain.ZhyArticle; |
|
|
|
|
|
import com.ruoyi.system.domain.ZhyDoc; |
|
|
import com.ruoyi.system.domain.ZhyDocRelation; |
|
|
import com.ruoyi.system.domain.ZhyDocRelation; |
|
|
import com.ruoyi.system.mapper.ZhyArticleMapper; |
|
|
import com.ruoyi.system.mapper.ZhyArticleMapper; |
|
|
import com.ruoyi.system.mapper.ZhyDocRelationMapper; |
|
|
import com.ruoyi.system.mapper.ZhyDocRelationMapper; |
|
|
|
|
|
import org.elasticsearch.search.SearchHit; |
|
|
import org.elasticsearch.search.SearchHits; |
|
|
import org.elasticsearch.search.SearchHits; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
@ -81,8 +83,19 @@ public class EsTestController { |
|
|
.withFuzzyMatch("abstracts",param) |
|
|
.withFuzzyMatch("abstracts",param) |
|
|
.buildAndExecute("links"); |
|
|
.buildAndExecute("links"); |
|
|
Map map = new HashMap(); |
|
|
Map map = new HashMap(); |
|
|
map.put("nodes",nodes); |
|
|
|
|
|
map.put("links",links); |
|
|
map.put("links",links); |
|
|
|
|
|
List<ZhyDocApi> nodes1=new ArrayList<>(); |
|
|
|
|
|
for(int i=0;i<links.getHits().length;i++){ |
|
|
|
|
|
SearchHit a=links.getHits()[i]; |
|
|
|
|
|
String dbid =(String) a.getSourceAsMap().get("DBid"); |
|
|
|
|
|
ZhyArticle article=zhyArticleMapper.selectZhyArticleById(Long.valueOf(dbid)); |
|
|
|
|
|
ZhyDocApi docSource=zhyDocApiMapper.selectDocByIdId(article.getSourceId()); |
|
|
|
|
|
ZhyDocApi docTarget=zhyDocApiMapper.selectDocByIdId(article.getTargetId()); |
|
|
|
|
|
nodes1.add(docSource); |
|
|
|
|
|
nodes1.add(docTarget); |
|
|
|
|
|
} |
|
|
|
|
|
map.put("nodes",nodes); |
|
|
|
|
|
map.put("nodes1",nodes1); |
|
|
return map; |
|
|
return map; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -105,6 +118,7 @@ public class EsTestController { |
|
|
.addField("DBid") |
|
|
.addField("DBid") |
|
|
.addField("type") |
|
|
.addField("type") |
|
|
.addField("abstracts") |
|
|
.addField("abstracts") |
|
|
|
|
|
.addField("data") |
|
|
.build(); |
|
|
.build(); |
|
|
elasticSearchUtil.createIndex("nodes",mappings); |
|
|
elasticSearchUtil.createIndex("nodes",mappings); |
|
|
elasticSearchUtil.createIndex("links",mappings); |
|
|
elasticSearchUtil.createIndex("links",mappings); |
|
|
@ -126,25 +140,30 @@ public class EsTestController { |
|
|
} |
|
|
} |
|
|
elasticSearchUtil.addDocBatch("nodes", bookList, ESDao.class, "id"); |
|
|
elasticSearchUtil.addDocBatch("nodes", bookList, ESDao.class, "id"); |
|
|
|
|
|
|
|
|
|
|
|
List<ESDao> bookList2 = new ArrayList<>(); |
|
|
ZhyArticle zhyArticle = new ZhyArticle(); |
|
|
ZhyArticle zhyArticle = new ZhyArticle(); |
|
|
List<ZhyArticle> lineList = zhyArticleMapper.selectZhyArticleList(zhyArticle); |
|
|
List<ZhyArticle> lineList = zhyArticleMapper.selectZhyArticleList(zhyArticle); |
|
|
for (int i=0;i<lineList.size();i++){ |
|
|
for (int i=0;i<lineList.size();i++){ |
|
|
String abstracts = lineList.get(i).getName()+lineList.get(i).getKeywords()+lineList.get(i).getSummary(); |
|
|
String abstracts = lineList.get(i).getName()+lineList.get(i).getKeywords()+lineList.get(i).getSummary(); |
|
|
|
|
|
System.out.println(abstracts); |
|
|
String id = String.valueOf(lineList.get(i).getId()); |
|
|
String id = String.valueOf(lineList.get(i).getId()); |
|
|
ZhyDocRelation zhyDocRelation = new ZhyDocRelation(); |
|
|
ZhyDocRelation zhyDocRelation = new ZhyDocRelation(); |
|
|
zhyDocRelation.setArticleId(lineList.get(i).getId()); |
|
|
zhyDocRelation.setArticleId(lineList.get(i).getId()); |
|
|
List<Map> a = zhyDocRelationMapper.selectZhyRelationshipArticle(zhyDocRelation); |
|
|
List<Map> a = zhyDocRelationMapper.selectZhyRelationshipArticle(zhyDocRelation); |
|
|
|
|
|
List<String> ids = new ArrayList<>(); |
|
|
|
|
|
for (int j = 0;j<a.size();j++){ |
|
|
|
|
|
ids.add(String.valueOf(a.get(j).get("id"))); |
|
|
|
|
|
} |
|
|
ESDao esDao = new ESDao(); |
|
|
ESDao esDao = new ESDao(); |
|
|
esDao.id = id; |
|
|
esDao.id = id; |
|
|
esDao.DBid = id; |
|
|
esDao.DBid = id; |
|
|
esDao.type = "line"; |
|
|
esDao.type = "line"; |
|
|
esDao.abstracts = abstracts; |
|
|
esDao.abstracts = abstracts; |
|
|
esDao.data = a; |
|
|
esDao.data = ids.toString(); |
|
|
bookList.add(esDao); |
|
|
bookList2.add(esDao); |
|
|
|
|
|
System.out.println(bookList2); |
|
|
} |
|
|
} |
|
|
elasticSearchUtil.addDocBatch("links", bookList, ESDao.class, "id"); |
|
|
elasticSearchUtil.addDocBatch("links", bookList2, ESDao.class, "id"); |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|