来自groovy.config的groovy打印环境(groovy print environments from groovy.config)
如何从配置文件中打印可用的环境? ojbect ConfigSlurper创建什么形式?
我试过了
def config2 = new ConfigSlurper().parse(new File('obieeadmincfg.groovy').toURL()) config2.config.environments.each { println ${it} } and println prettyPrint(toJson(config2)) and for ( i in 0 ..config2.config.environments.size()-1) println config2.config.environments[i]
groovy.config
//Config3.groovy obieadmin { //default values serverurl = "http://default.mycompany.com" } environments { pldev01 { obieeadmin { serverurl = 'devgdwobi03.x.com' } } plsbx02 { obieeadmin { serverurl = 'devgdwobi03.x.com' } } }
how do I print available environments from a config file? What is the form of the ojbect ConfigSlurper creates?
I tried
def config2 = new ConfigSlurper().parse(new File('obieeadmincfg.groovy').toURL()) config2.config.environments.each { println ${it} } and println prettyPrint(toJson(config2)) and for ( i in 0 ..config2.config.environments.size()-1) println config2.config.environments[i]
groovy.config
//Config3.groovy obieadmin { //default values serverurl = "http://default.mycompany.com" } environments { pldev01 { obieeadmin { serverurl = 'devgdwobi03.x.com' } } plsbx02 { obieeadmin { serverurl = 'devgdwobi03.x.com' } } }
原文:https://stackoverflow.com/questions/33394245
最满意答案
考虑为什么您的查询不起作用:
没有不同的,你有每行配对u和p的行。 当你使用DISTINCT时,如果同一个u有多行,匹配多个p,它应该如何排序? 那是一项不可能完成的任务。
如果你把它改成u.id的顺序,那么它就可以了。
顺便说一下,我鼓励您使用标签将查询限制为仅限于相关节点。 您还可以重新编写查询,以防止它发出重复项,并完全避免使用DISTINCT。
如果我们假设您感兴趣的节点标有:Person,您的查询可能是:
MATCH (p:Person) WHERE EXISTS( (p)-[:likes]-() ) RETURN p ORDER BY p.id DESC
Consider why your query isn't working:
Without the distinct, you have rows with each pairing of u and p. When you use DISTINCT, how is it supposed to order when there are multiple lines for the same u, matching to multiple p's? That's an impossible task.
If you change it to order by u.id instead, then it works just fine.
I do encourage you to use labels, by the way, to restrict your query only to relevant nodes. You can also rework your query to prevent it from emitting duplicates and avoid the need for DISTINCT completely.
If we assume the nodes you're interested in are labeled with :Person, your query might be:
MATCH (p:Person) WHERE EXISTS( (p)-[:likes]-() ) RETURN p ORDER BY p.id DESC
相关问答
更多-
如何通过密码查询获得neo4j中的不同标签和计数?(How to get different labels and their count in neo4j by cypher query?)[2022-04-13]
因为节点可以有多个标签和labels (n)返回代表这些标签的字符串集合,所以每个标签获得一个计数是非常复杂的。 在由三个节点和两个标签组成的图上,如{:A} , {:B}和{:A:B} , labels (n)返回三个不同的字符串集合。 而不是用两个节点计数:A和两个节点:B ,结果将是三个标签组合中的每一个的结果。 见控制台 。 要按每个标签进行汇总,而不是按标签集合进行汇总,则必须按集合中的值进行分组,这非常麻烦。 我有一个丑陋的方式来做到这一点,也许有人可以建议一个更好的方法:首先找出任何节点有最大 ... -
对于一般查询,Cypher是足够的,可能更快。 Gremlin与Cypher的优势在于您进入高级别的运行 - 在Gremlin中,您可以更好地定义精确的遍历模式(或您自己的算法),而在Cypher中,引擎会尝试找到最佳的运行解决方案。 我个人使用Cypher,因为它的简单,迄今为止,我还没有任何情况下,我不得不使用Gremlin(除了使用Gremlin graphML导入/导出功能)。 然而,我期望即使我需要使用Gremlin,我会这样做一个具体的查询,我会发现在网上,永远不会再回来。 您可以随时了解Cyp ...
-
在设置索引时我不确定这是否是Spring Data中的错误,但是使用REST索引手动创建索引: :POST /db/data/index/node { "name" : "location", "config" : { "provider" : "spatial", "geometry_type" : "point", "wkt" : "wkt" } } 我现在可以使用@Query注释中的cypher以最小的努力执行查询(显然会有更多参数): @Query(value ...
-
如果我理解正确,那么你需要计算节点的相互依赖性: MATCH (v1)-[:DEPENDS_ON]->(v2 {gav: 'A'}) WHERE EXISTS(v1.gav) OPTIONAL MATCH (v1)<-[:DEPENDS_ON]-(v3)-[:DEPENDS_ON]->(v2) WHERE EXISTS(v3.gav) WITH DISTINCT v1.gav AS gav, COUNT(v3) AS sortValue RETURN gav ORDER BY sortValu ...
-
使用定期收集 在Cypher中,您可以使用WITH将查询分解为步骤,并且可以通过将它们连接在一起来连接两个列表。 MATCH (e:Enzyme)-[:activated]->(compA:Compound), (e)-[:inhibited_by]->(compB:Compund) WITH e, COLLECT(compA)+COLLECT(compB) as compList UNWIND compList as comp WITH DISTINCT e, comp // if a comp can ...
-
Neo4j Cypher从包含排序的简单查询中删除重复项(Neo4j Cypher remove duplicates from simple query that contains ordering)[2023-10-28]
考虑为什么您的查询不起作用: 没有不同的,你有每行配对u和p的行。 当你使用DISTINCT时,如果同一个u有多行,匹配多个p,它应该如何排序? 那是一项不可能完成的任务。 如果你把它改成u.id的顺序,那么它就可以了。 顺便说一下,我鼓励您使用标签将查询限制为仅限于相关节点。 您还可以重新编写查询,以防止它发出重复项,并完全避免使用DISTINCT。 如果我们假设您感兴趣的节点标有:Person,您的查询可能是: MATCH (p:Person) WHERE EXISTS( (p)-[:likes]-() ... -
就像@chrylis指出的那样,你的错误似乎是你没有所需的罐子,因而也就是错误的问题。 现在从您的评论中,我发现您在理解maven和依赖关系时遇到了困难。 所以这是我为您制作的简单指南。 [了解这不是一站式指南,这个程序可能不会开箱即用。 它目前正在为我运行,但它取决于许多事情,包括你正在运行的neo4j版本和其他一些配置因素。 尽管如此,这应该足以让你入门。 ] 您需要在系统上安装maven。 maven上很少有很酷的教程。 一个在这里。 https://www.youtube.com/watch?v=a ...
-
您正在执行的查询以及Neo4j文档中针对Expand Into提供的示例不同。 示例查询在同一节点上开始和结束。 如果您希望计划程序首先找到两个节点并查看是否存在关系,那么您可以使用长度为1的shortestPath来最小化数据库命中。 PROFILE MATCH (n:Consumer {mobileNumber: "yyyyyyyyy"}), (m:Consumer {mobileNumber: "xxxxxxxxxxx"}) WITH n,m MATCH Path=shortestPath( ...
-
neo4j cypher保持路径强加的排序,以便稍后在查询中使用(neo4j cypher keep ordering imposed by path for later in the query)[2022-03-31]
您要求的是不同的节点,这表明该节点可能可以通过多个路径到达,因此可能存在于距起始节点多个距离处。 您应该在每个n的路径长度上使用min() (或max() ,具体取决于您的要求),而不是使用DISTINCT。 由于这些是聚合函数,因此每个n只能获得一行。 MATCH p=((:Start)-[:NEXT*..100]->(n:RELEVANT)) WHERE ALL(node IN nodes(p) WHERE ...) WITH n, min(length(p)) as distance WITH n ... -
优化Cypher查询Neo4j(Optimizing Cypher Query Neo4j)[2022-05-11]
如果我理解查询,我认为Cypher让这比你期望的要容易得多。 尝试这个: MATCH (start:Col {schema:"${DWMDATA}",table:"CHK_P_T80_ASSET_ACCT_AMT_DD"})-->(node:Col) WHERE start.schema <> node.schema RETURN start, node 虽然我不确定为什么要比较节点上的schema属性。 是否由传入的值修复了起始节点的schema ? 我可能不理解查询。 如果您正在寻找的不仅仅是连接到起 ...