cypher

How to calculate rank for float values in Neo4j?

核能气质少年 提交于 2020-01-06 04:50:11
问题 I am calculating a set of paths using apoc.algo.dijkstra. My goal is to assign a rank to each of the suggested paths. Important is all the weights among nodes are floats. Cypher code: ... WITH origin, target CALL apoc.algo.dijkstra(origin, target, 'link', 'Weight') yield path as path, weight as weight ... what I have now: Path 1 - Weight: 1.2344332423 Path 2 - Weight: 0.8432423321 Path 3 - Weight: 0.9144331653 Something what I need is: rank: 1, weight: 1.2344332423 rank: 2, weight: 0

Neo4j - Invalid Query error occured

对着背影说爱祢 提交于 2020-01-05 10:18:26
问题 I have tried following query in cypher. START other=node(*) WHERE other.FirstName =~ "(?i)dh.*" AND other.UserID <> 1 WITH other, me=node:node_auto_index(UserID = '1') MATCH me-[myR:friends]-(x) RETURN other.UserID, other.UserName, other.FirstName, other.LastName, other.ImagePath // myR.ApprovalStatus, COUNT(distinct pMutualFriends) AS mutualFriends //ORDER BY mutualFriends DESC LIMIT 100; but it is giving me error. These columns can't be listen in the WITH statement without renaming: me=node

neo4j improving cypher query performance

别来无恙 提交于 2020-01-05 10:16:39
问题 I have items graph db. each item is connected to multiple properties , which can be shared by multiple items . I add a search node which is defined by few properties . So I have (search_node) connected to multiple (properties_nodes) connected to multiple (items_nodes) Now I would like to get a list of items who answer this search by {x} properties or more. Ordered by number of matching properties. start se=node:node_auto_index(name = {name}), pr = node:node_auto_index(type="item_property")

Cypher FOREACH MERGE not hitting the index

眉间皱痕 提交于 2020-01-05 09:32:03
问题 I've got a following parametrized Cypher query: MERGE (p:Person {pid: {personId}}) ON CREATE SET p.value=rand() MERGE (c:Page {url: {pageUrl}}) ON CREATE SET c.value=rand() MERGE p-[:REL]->c FOREACH (tagValue IN {tags} | MERGE (t:Tag {value:tagValue}) MERGE c-[:hasTag]->t) This is very slow, the profiling shows: EmptyResult | +UpdateGraph(0) | +Eager(0) | +UpdateGraph(1) | +Eager(1) | +UpdateGraph(2) +----------------+------+--------+------------------------------+----------------------------

How to get spring neo4j cypher custom query to populate an array of child relationships

做~自己de王妃 提交于 2020-01-05 05:39:06
问题 Built-in queries to Spring Data Neo4j (SDN) return objects populated with depth 1 by default. This means that "children" (related nodes) of an object returned by a query are populated. That's good - there are actual objects on the end of references from objects returned by these queries. Custom queries are depth 0 by default. This is a hassle. In this answer, it is described how to get springboot neo4j to populate a related element to the target of a custom query - to achieve an extra one

How to use max() on a collection?

眉间皱痕 提交于 2020-01-05 05:33:08
问题 I have a dataset that looks something like this: CREATE (n {name:'main', val:3}) -[:r]-> ({name:'sub1', val:2}), (n)-[:r]->({name:'sub2', val:1}) Now, I need to find the maximum value for 'val' for all nodes that are connected to the node named 'main' (including 'main' too). So, in this case the answer is 3. Since the node named 'main' may not have any subnodes, I used OPTIONAL MATCH to find the subnodes, then combine all the vals found into a list and call max() on it, like so: MATCH (n

Cypher: Query that converts property from int to String is very slow and causes OutOfMemoryError in Neo4j server

怎甘沉沦 提交于 2020-01-05 04:15:07
问题 I need to migrate the type of a numerical property to be of type String. For that I wrote the simple following query: MATCH (n:Entity) SET n.id=toString(n.id) RETURN n It matches about 1,2 million entities (according to EXPLAIN), so I didn't expect it to be fast. However, it didn't terminate after more than 5 hours. In the meantime neo4j server (community, 3.0.4) ran at close to 100% load. I have this configured in the corresponding neo4j.conf: dbms.memory.heap.initial_size=4g dbms.memory

Finding matches between start nodes for common sources in neo4j

回眸只為那壹抹淺笑 提交于 2020-01-05 03:34:26
问题 As part of some analysis, I am trying to find targets that have more than 80% common origins for one-hop paths. The data is of the kind: all nodes are systems, and the only relationship that is relevant is ConnectsTo . So, I can write queries like match (n:system)-[r:ConnectsTo]->(m:system) return n,m to get the sources n for system m . I am looking to find all systems m that have 80% or more common source systems. Please advise how this could be done for all systems. I tried with collect but

Finding matches between start nodes for common sources in neo4j

有些话、适合烂在心里 提交于 2020-01-05 03:34:07
问题 As part of some analysis, I am trying to find targets that have more than 80% common origins for one-hop paths. The data is of the kind: all nodes are systems, and the only relationship that is relevant is ConnectsTo . So, I can write queries like match (n:system)-[r:ConnectsTo]->(m:system) return n,m to get the sources n for system m . I am looking to find all systems m that have 80% or more common source systems. Please advise how this could be done for all systems. I tried with collect but

How to find specific subgraph in Neo4j using where clause

拥有回忆 提交于 2020-01-05 03:06:07
问题 I have a large graph where some of the relationships have properties that I want to use to effectively prune the graph as I create a subgraph. For example, if I have a property called 'relevance score' and I want to start at one node and sprawl out, collecting all nodes and relationships but pruning wherever a relationship has the above property. My attempt to do so netted this query: start n=node(15) match (n)-[r*]->(x) WHERE NOT HAS(r.relevance_score) return x, r My attempt has two issues I