我正在尝试在cypher WHERE子句中使用正则表达式.我想匹配节点属性Text包含特定单词的节点,作为单词而不是其中的一部分.
MATCH (n:) WHERE n.Text =~ '\bword\b' return n;
Run Code Online (Sandbox Code Playgroud)
虽然我的图表中存在包含单词"word"的节点,但此查询不会返回任何内容.cypher是否允许使用标准正则表达式?正则表达式实现有限制吗?
在Actor/Movie演示图上,cypher在单独的数组中返回列名.
MATCH (n:Person) RETURN n.name as Name, n.born as Born ORDER BY n.born LIMIT 5
Run Code Online (Sandbox Code Playgroud)
结果:
{ "columns" : [ "Name", "Born" ], "data" : [ [ "Max von Sydow", 1929 ], [ "Gene Hackman", 1930 ], [ "Richard Harris", 1930 ], [ "Clint Eastwood", 1930 ], [ "Mike Nichols", 1931 ] ]}
Run Code Online (Sandbox Code Playgroud)
是否可以改为标记每个节点属性?
{ "nodes" : [ ["Name": "Max von Sydow", "Born": 1929 ], ...] }
Run Code Online (Sandbox Code Playgroud)
如果我返回节点而不是选定的属性,我会得到太多属性.
MATCH (n:Person) RETURN n LIMIT 5
Run Code Online (Sandbox Code Playgroud)
结果:
{ "columns" : [ "n" …Run Code Online (Sandbox Code Playgroud) 是否有可能在单个密码查询中提取有限的节点集和节点总数?
match (n:Molecule) with n, count(*) as nb limit 10 return {N: nb, nodes: collect(n)}
Run Code Online (Sandbox Code Playgroud)
上面的查询正确返回节点,但返回1作为节点数.我当然明白为什么它返回1,因为没有分组,但无法弄清楚如何纠正它.
我正在尝试使用d3在文本后面添加一个rect元素来模拟d3文本元素不存在的背景颜色.我希望rect具有与文本本身完全相同的大小.
node.append("text")
.attr("class", "text")
.attr("text-anchor", "middle")
.attr("dx", 0)
.attr("dy", ".35em")
.text(function(d) {
var bbox = this.getBBox();
node.insert("rect",":first-child")
.attr("x", bbox.x)
.attr("y", bbox.y)
.attr("width", bbox.width)
.attr("height", bbox.height)
.style("fill", "yellow");
return d.name;
});
Run Code Online (Sandbox Code Playgroud)
this.getBBox()为x和y返回0.
下面的代码显示该框,但它的大小与文本大小不同,即使文本不存在(当图像存在时)也会绘制框.
node.filter(function(d) {return (!d.image)}).append("text")
.attr("class", function(d) { return "text "+d.type; })
.attr("text-anchor", "middle")
.attr("dx", 0)
.attr("dy", ".35em")
//.text(function(d) { if (!d.imgB64) { return d.label; }
.text(function(d) {
return d.name;
})
.each(function(d) {
var bbox = this.getBBox();
node.insert("rect", "text")
.style("fill", "#FFE6F0")
.attr("x", bbox.x)
.attr("y", bbox.y)
.attr("width", bbox.width)
.attr("height", bbox.height);
}); …Run Code Online (Sandbox Code Playgroud)