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;
    }
}
相关推荐
SamChan906 小时前
Python+PyMuPDF提取PDF表格并翻译:表格结构检测与双语重建实战
windows·python·ai·pdf·wpf
weixin_307779136 小时前
PySpark根据输入的表名和过滤条件生成 INSERT 语句
python·spark·云计算·big data
GodSure09146 小时前
Java单一职责原则SRP详解
java·python·单一职责原则
探数API小喇叭6 小时前
基站查询 API 怎么用?LAC、CELLID 参数详解与实战】
java·开发语言·api·基站定位
catino6 小时前
spring-IOC、DI
java·spring·rpc
Mr.Lu ‍6 小时前
C++开发,使用openCV API对图片进行压缩
开发语言·c++·opencv
z落落6 小时前
C# WinForm NModbus 串口通信+WinForm Modbus4 串口通信
开发语言·单片机·c#
Mojitocean6 小时前
Win开发环境配置(持续更新)
开发语言·python