Here’s the table of contents:
- STRING类型的时间转为LONG类型
- 加载三元组数据-数据模型可视化插件支持的数据格式
- 并行执行Cypher
- 从CYPHER-TASK-ID中提取标签和关系类型
- CYPHER集合转换【LIST转为MAP】
- 并行批处理
- 使用正则提取圆括号和方括号中的值
- 寻找路径中的节点
- 虚拟节点和关系
- 聚簇查询
- 统计聚簇中
PREPCODE
节点和PRE统一社会信用代码
节点数量 - 在其它图库执行cypher语句
- 多字段唯一约束
- 多字段-复合索引
- 封装MAP
- 节点转为MAP
- 指定路径关系类型和层数之后返回
- 列表排重统计
- 将JSON中相关数据解析为LIST
- 返回元素在集合中的位置
- 从列表索引位开始删除几个元素
- 将列表元素按照序列连接为一条路径【使用默认关系类型】
- 将词序列解析为主节点和从节点模式
- 排重列表
- 解析N度路径信息
- 解析N度路径信息
- 按数据元素的索引位置获取数据
- 判断值是否包含在列表中
- MAP分组
- 列表转为map
- 入参方式获取map值
- 虚拟关系
- ListMap排序
- 不包含判断
- 保留两位小数
- 分层封装数据【获取指定结构的树】
- 唯一索引属性索引管理
- 匹配数字、英文、汉字
- 写一段Cypher代码,用来判断节点的name字段是否包含列表中某个值
STRING类型的时间转为LONG类型
WITH '20201123092403' AS hupdatetime
RETURN TOINTEGER(hupdatetime) AS lTime
加载三元组数据-数据模型可视化插件支持的数据格式
CALL apoc.load.jdbc('jdbc:mysql://testlab-contentdb-dev.crkldnwly6ki.rds.cn-north-1.alibaba.com.cn:3306/analytics_graph_data?user=dev&password=testlabgogo&useUnicode=true&characterEncoding=utf8&serverTimezone=UTC', 'SELECT `from`,relationship,`to` FROM ONGDB_TASK_CHECK_POINT') YIELD row WITH COLLECT(row) AS rowList WITH REDUCE(nodes=[],map IN rowList | nodes+({id:map.from,properties:{name:map.from}})) AS fromNodes,REDUCE(nodes=[],map IN rowList | nodes+({id:map.to,properties:{name:map.to}})) AS toNodes,REDUCE(relationships=[],map IN rowList | relationships+({type:map.relationship,startNode:map.from,endNode:map.to})) AS relationships
WITH apoc.coll.union(fromNodes,toNodes) AS nodes,relationships
RETURN {graph:{nodes:nodes,relationships:relationships}} AS graphData
并行执行Cypher
// 并行初始化并执行查询。
// 缺省情况下,最大分区数/并行数为CPU内核数 x 100;
// 最多批次数为10000。例如,如果Neo4j数据库被分配了4个内核,
// 那么并行的最多进程数为400。
CALL apoc.cypher.parallel(
fragment,
params,
parallelizeOn
) YIELD value
CALL apoc.cypher.parallel(
'MATCH (p:Person{name:$name}) -[:FRIEND_OF]-> (p1) RETURN p1.name AS name',
{name:['John','Mary','Peter','Wong','Chen','Lynas','Smith','Anna']},
'name'
)
从CYPHER-TASK-ID中提取标签和关系类型
RETURN apoc.text.regexGroups('HGRAPHSCHEMA(PREPCODE)-[公司注册号]->(PRE公司注册号)','((?!=,)([A-Za-z0-9_\u4e00-\u9fa5]+))+')
CYPHER集合转换【LIST转为MAP】
// 加载三元组映射配置【标准SCHEMA到数据SCHEMA的映射规则】【并转换为一个MAP】
CALL apoc.load.jdbc('jdbc:mysql://testlab-contentdb-dev.crkldnwly6ki.rds.cn-north-1.alibaba.com.cn:3306/analytics_graph_data?user=dev&password=testlabgogo&useUnicode=true&characterEncoding=utf8&serverTimezone=UTC', 'SELECT REPLACE(std_schema,\'HGRAPHSCHEMA\',\'\') AS std_schema,REPLACE(data_schema,\'HGRAPHTASK\',\'\') AS data_schema FROM ONGDB_SCHEMA_MAPPING') YIELD row WITH COLLECT(row) AS rowList
// LIST转为MAP
RETURN REDUCE(map={},row IN rowList | apoc.map.setEntry(map,row.data_schema,row.std_schema))
并行批处理
// 并行执行三次
CALL apoc.cypher.mapParallel('UNWIND range(0,$size) AS b RETURN b',{size:3},range(1,3))
使用正则提取圆括号和方括号中的值
RETURN apoc.text.regexGroups('MATCH p=(:公司)-[:担保]->(org:公司)-[:拥有]->(:品牌)<-[:包含]-(:产品) WHERE org.hcode='HORGcadb43d05c7d7596e5df3135d476424b' RETURN p','((?!=,)([A-Za-z0-9_\u4e00-\u9fa5]+))+')
寻找路径中的节点
MATCH (startNode:行业 {name:'轻工'}) WITH startNode
CALL apoc.path.subgraphAll(startNode, {maxLevel:2, relationshipFilter:'NEXT>', labelFilter:'行业', bfs:true, filterStartNode:false, limit:-1}) yield nodes,relationships RETURN *
MATCH (startNode:行业 {name:'轻工'}) WITH startNode
CALL apoc.path.subgraphNodes(startNode, {maxLevel:2, relationshipFilter:'NEXT>', labelFilter:'行业', bfs:true, filterStartNode:false, limit:-1}) yield node RETURN *
虚拟节点和关系
CREATE (n),(m) WITH n,m CALL apoc.create.vRelationship(n,'KNOWS',{since:2010}, m) YIELD rel RETURN rel
CALL apoc.create.vNode(['Person'],{name:'John'}) YIELD node RETURN node
CALL apoc.create.vPattern({_labels:['Person'],name:'John'},'KNOWS',{since:2010},{_labels:['Person'],name:'Jane'}) YIELD from,rel,to RETURN from,rel,to
CALL apoc.create.vPatternFull(['Person'],{name:'John'},'KNOWS',{since:2010},['Person'],{name:'Jane'}) YIELD from,rel,to RETURN from,rel,to
聚簇查询
// 有多个主体形成的聚簇,当前主体肯定自己是一个聚簇,这样的逻辑顺序去查
WITH 'caihi2api1012290188' AS parent_pcode
// 一个主体形成的聚簇
MATCH (sou:PREPCODE)-->(mid) WHERE sou.name=parent_pcode WITH parent_pcode
// 多主体形成的聚簇
OPTIONAL MATCH (sou:PREPCODE)-->(mid)<--(tar:PREPCODE) WHERE sou.name=parent_pcode AND mid.name<>'' WITH parent_pcode,tar.name AS cluster_pcode
RETURN apoc.coll.union([parent_pcode],COLLECT(cluster_pcode)) AS parent_pcode_list
统计聚簇中PREPCODE
节点和PRE统一社会信用代码
节点数量
- 单个code获取获取聚簇统计值
WITH 'caihui21012467984' AS parent_pcode // 一个主体形成的聚簇 MATCH (sou:PREPCODE) WHERE sou.name=parent_pcode WITH sou // 扩展路径【返回所有可到达的PREPCODE节点】 CALL apoc.path.subgraphNodes(sou,{maxLevel:-1, relationshipFilter:'中文名称|英文名称|曾用名|纳税人识别号|地税登记号码|国税登记号码|营业执照号码|统一社会信用代码', labelFilter:'+PREPCODE|+PRE公司中文名称|+PRE国税登记号码|+PRE地税登记号码|+PRE曾用名|+PRE纳税人识别号|+PRE统一社会信用代码|+PRE英文名称|+PRE营业执照号码|-PRE公司注册号', bfs:false, filterStartNode:false,uniqueness:'NODE_GOLBEL', limit:-1}) YIELD node WITH node WITH COLLECT(node) AS nodeList WITH FILTER(node IN nodeList WHERE LABELS(node)[0]='PREPCODE') AS pcodeNodeList,FILTER(node IN nodeList WHERE LABELS(node)[0]='PRE统一社会信用代码') AS creditNodeList RETURN SIZE(pcodeNodeList) AS pcodeNodeSize,SIZE(creditNodeList) AS creditNodeSize
- 单个code获取获取聚簇统计值-同时返回聚簇pcode列表
WITH 'caihui21012467984' AS parent_pcode // 一个主体形成的聚簇 MATCH (sou:PREPCODE) WHERE sou.name=parent_pcode WITH sou // 扩展路径【返回所有可到达的PREPCODE节点】 CALL apoc.path.subgraphNodes(sou,{maxLevel:-1, relationshipFilter:'中文名称|英文名称|曾用名|纳税人识别号|地税登记号码|国税登记号码|营业执照号码|统一社会信用代码', labelFilter:'+PREPCODE|+PRE公司中文名称|+PRE国税登记号码|+PRE地税登记号码|+PRE曾用名|+PRE纳税人识别号|+PRE统一社会信用代码|+PRE英文名称|+PRE营业执照号码|-PRE公司注册号', bfs:false, filterStartNode:false,uniqueness:'NODE_GOLBEL', limit:-1}) YIELD node WITH node WITH COLLECT(node) AS nodeList WITH FILTER(node IN nodeList WHERE LABELS(node)[0]='PREPCODE') AS pcodeNodeList,FILTER(node IN nodeList WHERE LABELS(node)[0]='PRE统一社会信用代码') AS creditNodeList RETURN REDUCE(list=[],pcodeNode IN pcodeNodeList | list+pcodeNode.name) AS pcodeList,SIZE(pcodeNodeList) AS pcodeNodeSize,SIZE(creditNodeList) AS creditNodeSize
- 批量获取聚簇统计值
WITH ['caihui180108875', 'qixinbao5c9a0ba7-686f-4565-9f04-d163887947be', 'jy80648', 'nfdp_infoPTY000156036', 'caihui2api1002386630', 'nfdp_infoPTY000156037', 'caihui2api1002637994', 'caihui2api1012467984', 'caihui180153107', 'caihui21012467984', 'ARTfe01375441c7d737664b1baaf41e25d1', 'nfdp_infoPTY000156024', 'jy80646', 'chinascopeCSF0000143952', 'gshang7ddbbb7c-5abb-49ed-b5e4-fd4698fee39c', 'caihui21002637994', 'caihui180153109', 'chinascopeCSF0000013157', 'caihui2api1007242551', 'nfdp_infoPTY000119360', 'chinascope3CSF0000191942', 'chinascope2CSF0000191942', 'chinascopeCSF0000191942', 'gshang65d46b9b-c1e2-453f-bea6-c423cec8a740', 'qixinbao65d46b9b-c1e2-453f-bea6-c423cec8a740', 'jy80643', 'caihui180134043', 'wind45C863428F', 'caihui21007242551', 'nfdp_infoPTY000156038', 'jy80651', 'gshang88aa4fa3-2030-46de-ba71-5ad5170d5921', 'qixinbao88aa4fa3-2030-46de-ba71-5ad5170d5921', 'caihui2api1004688014', 'caihui180153112', 'caihui21004688014', 'ART5722eaab9cc3b631d3e643e5ee567937', 'wind3IO72C83B4', 'jy80649', 'gshang4ac51cdd-6792-4529-b920-3f592ce48fb4', 'qixinbao4ac51cdd-6792-4529-b920-3f592ce48fb4', 'ART23c205b21102797b4ba89a6c4d2939fe', 'wind2AF4D7336F', 'caihui21002386630', 'gshang5c9a0ba7-686f-4565-9f04-d163887947be', 'chinascopeICN5056968738', 'ART1e132e3175ea25341ef2c6b66166b40d', 'wind2AF4DC117B'] AS pcodeList UNWIND pcodeList AS parent_pcode // 一个主体形成的聚簇 MATCH (sou:PREPCODE) WHERE sou.name=parent_pcode WITH sou,parent_pcode // 扩展路径【返回所有可到达的PREPCODE节点】 CALL apoc.path.subgraphNodes(sou,{maxLevel:-1, relationshipFilter:'中文名称|英文名称|曾用名|纳税人识别号|地税登记号码|国税登记号码|营业执照号码|统一社会信用代码', labelFilter:'+PREPCODE|+PRE公司中文名称|+PRE国税登记号码|+PRE地税登记号码|+PRE曾用名|+PRE纳税人识别号|+PRE统一社会信用代码|+PRE英文名称|+PRE营业执照号码|-PRE公司注册号', bfs:false, filterStartNode:false,uniqueness:'NODE_GOLBEL', limit:-1}) YIELD node WITH node,parent_pcode WITH parent_pcode,COLLECT(node) AS nodeList WITH parent_pcode,FILTER(node IN nodeList WHERE LABELS(node)[0]='PREPCODE') AS pcodeNodeList,FILTER(node IN nodeList WHERE LABELS(node)[0]='PRE统一社会信用代码') AS creditNodeList RETURN parent_pcode,SIZE(pcodeNodeList) AS pcodeNodeSize,SIZE(creditNodeList) AS creditNodeSize
在其它图库执行cypher语句
CALL apoc.bolt.load("bolt://user:password@localhost:7687","match(p:Person {name:{name}}) return p", {name:'Michael'}) YIELD row RETURN row
多字段唯一约束
- 创建约束
CREATE CONSTRAINT ON (n:Test) ASSERT (n.name,n.code) IS NODE KEY;
- 删除约束
DROP CONSTRAINT ON (n:Test) ASSERT (n.name,n.code) IS NODE KEY;
CREATE (n:Test {name:'Jhon',code:'NUM-1'}) RETURN n; MATCH (n:Test {name:'Jhon',code:'NUM-1'}) RETURN n;
https://neo4j.com/docs/cypher-manual/current/administration/constraints/
多字段-复合索引
CREATE INDEX ON :Label(name,hupdatetime);
封装MAP
- apoc.map.setEntry
MATCH (n) RETURN apoc.map.setEntry({},TOSTRING(ID(n)),'') LIMIT 10
- apoc.map.setPairs
WITH {} AS vFMap WITH apoc.map.setPairs(vFMap,[["key1","value"],["key2","value"]]) AS vFMap RETURN vFMap
- apoc.map.setPairs
WITH {} AS vFMap MATCH (n0)-[r0]->(n1) WITH n0,r0,n1,vFMap LIMIT 1 WITH apoc.map.setPairs(vFMap,[[TOSTRING(ID(n0)),"value"],[TOSTRING(ID(r0)),"value"],[TOSTRING(ID(n1)),"value"]]) AS vFMap RETURN vFMap
- apoc.map.setPairs
RETURN apoc.map.setPairs({},[[TOSTRING(1),'value'],[TOSTRING(2),'value'],[TOSTRING(1),'value2']])
- apoc.map.removeKeys
RETURN apoc.map.removeKeys({num:1,sort:102},['num'])
节点转为MAP
RETURN apoc.convert.toMap(node)
指定路径关系类型和层数之后返回
MATCH p=()-[r:`采购`*4]->() RETURN p LIMIT 1
MATCH p=(n:HORGShareHoldV002)<-[r:`持股`*100]-() WHERE n.name='天津秦岭商业管理有限公司' RETURN p LIMIT 1
// 层数100表示:相当于101张表之间做100次JOIN
// 测试穿透一百层:
// LIMIT 1 -> 91 ms
// LIMIT 10 -> 407 ms
// 测试穿透一千层,获取一条路径耗时,54s
列表排重统计
WITH [1,2,32,2,1] AS list
UNWIND list AS id
WITH COLLECT(DISTINCT id) AS ids
RETURN SIZE(ids) AS size
将JSON中相关数据解析为LIST
WITH '{"data":{"modelYanBaoTextAnalyzer":[{"word":"科大讯飞","description":"自定义词","tag":"uw"},{"word":"阿里巴巴","description":"自定义词","tag":"uw"}]}}' AS data
WITH apoc.convert.fromJsonMap(data).data.modelYanBaoTextAnalyzer AS listMap
RETURN REDUCE(list=[],map IN listMap | list+map.word) AS list
返回元素在集合中的位置
RETURN apoc.coll.indexOf(['百度','阿里巴巴','获得','荣誉','称号'],'获得') AS eleIndexOf
从列表索引位开始删除几个元素
RETURN apoc.coll.remove(['百度','阿里巴巴','获得','荣誉','称号'],0,1) AS eleRemove
将列表元素按照序列连接为一条路径【使用默认关系类型】
// 相邻元素组成的所有可能子集集合
RETURN apoc.coll.pairs(['百度','阿里巴巴','获得','荣誉','称号']) AS elePairs
RETURN apoc.coll.pairs([['百度'],['阿里巴巴'],['获得'],['荣誉'],['称号']]) AS elePairs
WITH ['百度','阿里巴巴','获得','荣誉','称号'] AS list
WITH apoc.coll.pairs(['百度','阿里巴巴','获得','荣誉','称号']) AS elePairs
UNWIND elePairs AS pair
RETURN pair[0] AS startWord,pair[1] AS endWord
将词序列解析为主节点和从节点模式
WITH ['百度','阿里巴巴','获得','荣誉','称号'] AS rawList
// apoc.map.setPairs封装MAP;
// apoc.coll.indexOf获取元素在列表中的索引位;
// apoc.coll.pairs相邻元素组成的所有可能子集集合;
WITH REDUCE(list=[],ele IN rawList | list+apoc.map.setPairs({},[['word',ele],['id',apoc.coll.indexOf(rawList,ele)]])) AS list
WITH apoc.coll.pairs(list) AS elePairs
UNWIND elePairs AS pair
WITH pair
WHERE pair[1] IS NOT NULL
RETURN pair[0] AS startWord,pair[1] AS endWord
排重列表
RETURN apoc.coll.toSet(['阿里巴巴','百度','字节跳动','百度']) AS uniqueSet
解析N度路径信息
MATCH p=(:公司)-[r:持股*3]->(:公司) WITH p LIMIT 10
WITH RELATIONSHIPS(p) AS rels
UNWIND rels AS rel
WITH STARTNODE(rel) AS start,rel,ENDNODE(rel) AS end
RETURN ID(start) AS startId,LABELS(start) AS startLabel,PROPERTIES(start) AS startPros,ID(rel) AS relId,TYPE(rel) AS relType,PROPERTIES(rel) AS relPros,ID(end) AS endId,LABELS(end) AS endLabel,PROPERTIES(end) AS endPros
解析N度路径信息
// 生成词列表
MATCH (n:`关键词`) WITH n LIMIT 100
WITH COLLECT(n.name) AS wordList
WITH REDUCE(list=[],word IN wordList | list+apoc.map.setPairs({},[['id',olab.schema.atomic.id()],['word',word]])) AS wordList
UNWIND wordList AS first
UNWIND wordList AS second
WITH first,second
WHERE first.id<second.id
WITH first.word AS first,second.word AS second
MATCH (o:关键词),(s:关键词) WHERE o.name=first AND s.name=second
CALL custom.jaccard.agg.lr.sum(first,second) YIELD sId,oId,l_jaccard,r_jaccard,aggSim RETURN sId,algo.asNode(sId).name AS sIdName,oId,algo.asNode(oId).name AS oIdName,l_jaccard,r_jaccard,aggSim ORDER BY aggSim DESC
按数据元素的索引位置获取数据
WITH ['HDOC20576c537a9e43cac0cf0c84af855cb1','HDOC6f71374f00bf0728f3138a9d71fe8133','HDOC0bc72c20b09392fd3cee05906c097e27'] as ybHcode,
['HCEPTd16ad3643ad25f6c72410bac1584b14b','HCEPT2da2204d4639c81168f91b20b13c4d6b','HCEPTcdca00d8295a179c6c74596f559399d8'] AS conceptHcode
UNWIND ybHcode AS first
WITH first,conceptHcode[apoc.coll.indexOf(ybHcode,first)] AS second
RETURN first,second
判断值是否包含在列表中
RETURN apoc.coll.contains([1,2],3)
MAP分组
RETURN apoc.map.groupBy([{id:0,a:1},{id:1, b:false},{id:0,c:2}],'id') as value
RETURN apoc.map.groupByMulti([{id:0,a:1},{id:1, b:false},{id:0,c:2}],'id') as value
列表转为map
RETURN apoc.map.fromLists(['a','b'],[1,false]) AS value
入参方式获取map值
RETURN apoc.map.get({a:1},'a') AS value
RETURN apoc.map.get({a:1},'c',42) AS value
RETURN apoc.map.get({a:1},'c',null,false) AS value
虚拟关系
CREATE (n),(m) WITH n,m CALL apoc.create.vRelationship(n,'KNOWS',{since:2010}, m) YIELD rel RETURN rel
ListMap排序
WITH [{date:2021,amount:1020},{date:2010,amount:120},{date:2015,amount:620},{date:2020,amount:920}] AS l RETURN apoc.coll.sortMaps(l,'^date') as maps
不包含判断
RETURN NOT ('string_str2' CONTAINS 'str3') AS bool
保留两位小数
WITH 2 as precision
WITH toFloat('12.336666') AS value, 10^precision AS factor
RETURN round(factor * value)/factor AS value
RETURN ROUND(10^2*TOFLOAT('12.336666'))/10^2 AS value
分层封装数据【获取指定结构的树】
// 匹配需要处理的路径
MATCH p=(c:Class {name:'电影'})-[r1:实例]->(m:Movie)<-[r2:ACTED_IN]-(:Person)
// 收集两层关系
WITH COLLECT(DISTINCT r1) AS hc_r1,COLLECT(DISTINCT r2) AS hc_r2
// 解析第一层NODE,第二层NODE,第三层NODE
// NODE对象结构:node-当前层节点,f_node表示父级节点,rel表示当前节点的关系
WITH REDUCE(l=[],r IN hc_r1 | l+apoc.map.setPairs({},[["node",ID(STARTNODE(r))],["rel",ID(r)]])) AS hc_n1,
REDUCE(l=[],r IN hc_r1 | l+apoc.map.setPairs({},[["f_node",ID(STARTNODE(r))],["node",ID(ENDNODE(r))],["rel",ID(r)]])) AS hc_n2,
REDUCE(l=[],r IN hc_r2 | l+apoc.map.setPairs({},[["f_node",ID(ENDNODE(r))],["node",ID(STARTNODE(r))],["rel",ID(r)]])) AS hc_n3
// 通过上一次处理后,每一层节点、关联关系以及父级节点都准备好了,下一步需要将`node`排重,然后将`f_node`和`rel`收集在一个数组
// 当前节点的父级节点和关联关系可能有多个,所以排重后需要增加两个map字段`f_nodes`和`rels`
WITH hc_n1,hc_n2,hc_n3
WITH apoc.map.groupByMulti(hc_n1,'node') AS hc_n1_gp,EXTRACT(map IN hc_n1 | map.node) AS hc_n_l1,
apoc.map.groupByMulti(hc_n2,'node') AS hc_n2_gp,EXTRACT(map IN hc_n2 | map.node) AS hc_n_l2,
apoc.map.groupByMulti(hc_n3,'node') AS hc_n3_gp,EXTRACT(map IN hc_n3 | map.node) AS hc_n_l3
// 封装最终返回的每一层数据格式[{cur_node:node,f_nodes:[2,123],rels:[213,23]}]
WITH REDUCE(l=[],nd IN hc_n_l1 | l+apoc.map.setPairs({},[["cur_node",nd],["f_nodes",apoc.coll.toSet(FILTER(e IN EXTRACT(mp IN apoc.map.get(hc_n1_gp,TOSTRING(nd),NULL,FALSE) | mp.f_node) WHERE e IS NOT NULL))],["rels",apoc.coll.toSet(FILTER(e IN EXTRACT(mp IN apoc.map.get(hc_n1_gp,TOSTRING(nd),NULL,FALSE) | mp.rel) WHERE e IS NOT NULL))]])) AS hc1,
REDUCE(l=[],nd IN hc_n_l2 | l+apoc.map.setPairs({},[["cur_node",nd],["f_nodes",apoc.coll.toSet(FILTER(e IN EXTRACT(mp IN apoc.map.get(hc_n2_gp,TOSTRING(nd),NULL,FALSE) | mp.f_node) WHERE e IS NOT NULL))],["rels",apoc.coll.toSet(FILTER(e IN EXTRACT(mp IN apoc.map.get(hc_n2_gp,TOSTRING(nd),NULL,FALSE) | mp.rel) WHERE e IS NOT NULL))]])) AS hc2,
REDUCE(l=[],nd IN hc_n_l3 | l+apoc.map.setPairs({},[["cur_node",nd],["f_nodes",apoc.coll.toSet(FILTER(e IN EXTRACT(mp IN apoc.map.get(hc_n3_gp,TOSTRING(nd),NULL,FALSE) | mp.f_node) WHERE e IS NOT NULL))],["rels",apoc.coll.toSet(FILTER(e IN EXTRACT(mp IN apoc.map.get(hc_n3_gp,TOSTRING(nd),NULL,FALSE) | mp.rel) WHERE e IS NOT NULL))]])) AS hc3
RETURN hc1,hc2,hc3
唯一索引属性索引管理
CALL db.constraints()
CALL db.indexes()
CALL db.constraints() YIELD description WHERE description CONTAINS 'PRE' OR description CONTAINS 'pre' RETURN description
UNION
CALL db.indexes() YIELD description WHERE description CONTAINS 'PRE' OR description CONTAINS 'pre' RETURN description
匹配数字、英文、汉字
RETURN apoc.text.regreplace('{}[]Hellosad #$#$#$#@%%^&&**)-=W123orld!中文号码號碼``,;.[]', '[^a-zA-Z0-9\u4e00-\u9fa5]', '') AS value
写一段Cypher代码,用来判断节点的name字段是否包含列表中某个值
WITH ['name1', 'name2', 'name3'] AS list
MATCH (n)
WHERE ANY(e IN list WHERE n.name CONTAINS e)
RETURN n;
PREVIOUS常用CYPHER查询(一)
NEXT常用CYPHER查询(二)