简体   繁体   English

Neo4J 密码查询在某些情况下不返回结果

[英]Neo4J cypher query do not return results in some situations

I have a query in Neo4j to calculate the path with the lowest transition cost between items.我在 Neo4j 中有一个查询来计算项目之间转换成本最低的路径。 In my case I know exactly what are the types of elements to go including the depth .. here's an example:就我而言,我确切地知道要使用的元素类型是什么,包括 depth .. 这是一个例子:

MATCH path = (n0: TermOccurrence) - [: CONNECTS] -> (n1: TermOccurrence) - [: CONNECTS] -> (n2: TermOccurrence) - [: CONNECTS] -> (n3: TermOccurrence) WHERE n0.termName = ' n 'AND n1.termName =' a 'AND n2.termName =' x 'AND n3.termName =' e 'RETURN path AS shortestPath, REDUCE (cost = 0, r in RELATIONSHIPS (path) | cost + r.transitionCost) AS totalCost ORDER BY totalCost ASC LIMIT 1 MATCH path = (n0: TermOccurrence) - [: CONNECTS] -> (n1: TermOccurrence) - [: CONNECTS] -> (n2: TermOccurrence) - [: CONNECTS] -> (n3: TermOccurrence) WHERE n0.termName = ' n 'AND n1.termName =' a 'AND n2.termName =' x 'AND n3.termName =' e 'RETURN path AS shortestPath, REDUCE (cost = 0, r in RELATIONSHIPS (path) | cost + r.transitionCost) AS totalCost ORDER BY totalCost ASC LIMIT 1

In this case as a result of the query I get the lowest cost path correctly however when I change the values ​​of the termName fields from 'n' 'a' 'x' 'e' to 'n', 'a', 'n', 'a 'the result is empty ... I suspect cypher is not accepting duplicate relationships in the traversal path ... Has anyone been through something similar?在这种情况下,作为查询的结果,我正确地获得了最低成本路径,但是当我将 termName 字段的值从 'n' 'a' 'x' 'e' 更改为 'n'、'a' 时, 'n', 'a ' 结果是空的......我怀疑 cypher 不接受遍历路径中的重复关系......有没有人经历过类似的事情? My db is organized as follows:我的数据库组织如下:

TermOccurrence -> [: Connects] -> TermOccurrence TermOccurrence -> [: Connects] -> TermOccurrence

Thanks Enzo谢谢恩佐

Ok !好的 ! this is my path when i query for the string 'n' 'a' 'x' 'e' : naxe img这是我查询字符串 'n' 'a' 'x' 'e' 时的路径naxe img

This is my path when i query for the string 'n' 'a' 'n' 'e' : name img这是我查询字符串 'n' 'a' 'n' 'e' 时的路径: name img

And finally when i query for the string 'n' 'a' 'n' 'a' nana img最后当我查询字符串 'n' 'a' 'n' 'a' nana img

I think this is happening because n->a relationship occurs more than one time on path but in my model this is perfectly normal... What I don't know is if there is a way around this restriction with neo4j...我认为这是因为 n-> 关系在路径上出现不止一次,但在我的模型中这是完全正常的......我不知道是否有办法解决 Neo4j 的这种限制......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM