Java代码实现根据节点属性信息模糊查询节点

Neo4jUtil.java

java 复制代码
@Component
@Slf4j
public class Neo4jUtil {
@Resource
    private Session session;

    public List<Map<String,Object>> getNodeInfoByNodeName(String nodeName) {

        List<Map<String,Object>> dataList = new ArrayList<>();
         if (StrUtil.isBlank(nodeName)) {
             return dataList;
         }

         //拼装查询语句
        String cypherSql = String.format("MATCH (n) where n.name=~ '.*%s.*' RETURN n  ", nodeName);
        Result query = session.query(cypherSql, new HashMap<>(16));

        for (Map<String, Object> map : query.queryResults()) {
            NodeModel queryNode = (NodeModel) map.get("n");
            Long neo4jId = queryNode.getId();
            String[] labels = queryNode.getLabels();
            List<Property<String, Object>> propertyList = queryNode.getPropertyList();
            Map<String,Object> dataMap = new HashMap<>(5);
            for (Property<String, Object> stringObjectProperty : propertyList) {
                dataMap.put(stringObjectProperty.getKey(), stringObjectProperty.getValue());
                dataMap.put("neo4jId",neo4jId);
                dataMap.put("labels",labels);

            }
            dataList.add(dataMap);
        }
        session.clear();
        return dataList;
    }
}
相关推荐
ch62322 分钟前
🚀 从零构建本地文档智能审查 Agent:Vibe Coding 实战指南
python
FRing0341 分钟前
vue3干货总结3(defineOptions(Vue3.3)、defineModel(Vue3.4)、Pinia)
开发语言·前端·vue.js·vue3
摇滚侠1 小时前
《On Java 中文版 基础卷》阅读笔记 接口 18
java·笔记·python
CoderYanger1 小时前
Java EE 进阶:9.MyBatis 操作数据库(进阶)(第八弹):MyBatis Generator
java·数据库·spring boot·spring·java-ee·tomcat·mybatis
Thanks_ks1 小时前
AI Agent 开发入门:用 Function Calling 让大模型学会 “动手干活”,附订单查询机器人实战
python·ai·大模型·openai·agent·通义千问·mcp
专注仿真2 小时前
智能体训练之模仿学习:GAIL 算法详解与实战
python·算法·仿真·多智能体强化学习·afsim智能体训练
whitelbwwww2 小时前
CUDA C++实战--中级
开发语言·前端·c++
FungLeo3 小时前
FengCMS · PHP+MySQL 升级实录 · 内容写入一致性:锁等待超时与跨模型子树删除竞态
开发语言·mysql·php·工程实践·fengcms
databook3 小时前
处理一批 PDF,怎么算真的处理完了
后端·python
jaysee-sjc4 小时前
【黑马点评】Day02:优惠券秒杀与分布式锁
java·分布式·nginx·spring·node.js·tomcat·maven