Source: https://dev-docs.yueshu.com.cn/v5.3.2/utilities/exchange/config/sources/neo4j/ Documentation version: v5.3.2 # Neo4j 配置 本文介绍从 Neo4j 数据源导入数据的配置项。关于完整配置文件和配置项的信息,请参见[数据导入配置](https://dev-docs.yueshu.com.cn/v5.3.2/utilities/exchange/config/)。 ## 数据源配置 []() 下表列出了 Neo4j 数据源特定的配置项: | 选项 | 描述 | 类型 | 是否必选 | 默认值 | `type` | 数据源的类型。设置为`"neo4j"`。 | String | 是 | 无 | `server` | 使用 bolt 协议连接的 Neo4j 服务器的地址和端口。 | String | 是 | 无 | `user` | Neo4j 服务器的用户名。 | String | 是 | 无 | `password` | 用户的密码。 | String | 是 | 无 | `database` | 从中检索数据的数据库的名称。 | String | 否 | 无 | `encryption` | 连接是否启用加密。 | Bool | 否 | `false` | `statement` | Cypher 语句,用于从 Neo4j 检索数据。 | String | 是 | 无 | `queryCount` | 返回`count`字段的 Cypher 语句或者具体的数值,用于表示`statement`中 Cypher 语句返回数据的数量。 | Object | 是 | 无 | `readParallel` | 允许的并发读请求数。 | Int | 否 | `32` ## 通用源配置 下列配置项也可以作为全局设置在配置文件的`sourcesCommon`一节指定: - `type` - `server` - `user` - `password` - `database` - `encryption` - `readParallel` 请注意,针对特定数据源的配置会覆盖全局设置。 ## 数据源配置示例 Neo4j 源配置 ```` sources: [ { type:"neo4j" server: "bolt://127.0.0.1:7687" user: neo4j password: neo4j database: default encryption: false statement: "match (v:movie) return v.id as id, v.name as name" queryCount: "match (v:movie) return count(*) as count" // queryCount: 1000 readParallel: 32 // nodetypes: [] // edgetypes: [] } ] ```` ## 完整配置示例 将``替换为登录账号的当前密码。若已修改密码,请使用修改后的密码。 ```` { taskType: import nebula: { graphAddr: "127.0.0.1:9669" graphName: "movie" user: "root" passwd: "" } error: { path: "/tmp/errors" maxRecords: 10000 } checkPoint: { path: "/tmp/checkpoint" resume: false } sourcesCommon:{ type:"neo4j" server: "bolt://127.0.0.1:7687" user: neo4j password: neo4j readParallel: 32 } writeCommon:{ batchSize: 2000 enableRealTimeQPSLog: true mode: "INSERT IGNORE" } sources: [ # node type Actor { statement:"match (v:actor) return v.id as people_id, v.name as name, v.birth_date as birth_date" queryCount: "match (v:actor) return count(*) as count" pre_processes: { filter: ["birth_date!='\\N'"] concatConstant: [ { field: "name" prefixValue: "test_" suffixValue: "" } ] } nodetypes: [ { name: "Actor" sourceFields: [people_id,name,birth_date] nebulaFields: [id,name,birthDate] } ] } # node type Movie { statement:"match (v:movie) return v.id as movie_id, v.name as name" queryCount: "match (v:movie) return count(*) as count" nodetypes: [ { name: "Movie" sourceFields: [movie_id,name] nebulaFields: [id,name] } ] } # edge type Act { statement:"match (v1)-[e:act]->(v2) return e.src as people_id, e.dst as movie_id" queryCount: "match (v1)-[e:act]->(v2) return count(*) as count" edgetypes: [ { name: "Act" sourceKeys: [people_id] nebulaSrcKeys: [id] targetKeys: [movie_id] nebulaDstKeys: [id] sourceFields: [] nebulaFields: [] } ] } ] } ````