neo4j

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

Neo4j: full-text lucene legacy indexes (node_auto_index) does not work after migration

萝らか妹 提交于 2020-01-05 04:18:12
问题 After successful migration from Neo4j 2.2.8 to 3.0.4 using official faq, full text search does not work as expected. Fuzziness is not that fuzzy as it was before. Example: START n=node:node_auto_index('name:(+Target~0.85)') MATCH (n) RETURN n; Should return nodes with field name that contain work like 85% similar to 'Target'. Before it was matching the following: Target Target v2 After migration: Target Why and how to fix that? 回答1: Reason was that after migration lucene node_auto_index wasn

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

Use @NodeEntity on interface/abstract class

核能气质少年 提交于 2020-01-05 03:35:36
问题 Is it possible to add @NodeEntity (or even @RelationshipEntity ) annotation from SpringData Neo4j on an interface or abstact class or their fields? If not, how do you manage these situations? 回答1: Definitely you can do that on Abstract classes , and I think it's a good practice in some common cases. Let me give you an example that I'm using in my graph model: @NodeEntity public abstract class BasicNodeEntity implements Serializable { @GraphId private Long nodeId; public Long getNodeId() {

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

Spring Neo4j: Same cypher query taking different time when executed through different consoles

让人想犯罪 __ 提交于 2020-01-05 03:03:47
问题 Same cypher query taking different time when executed through different consoles: Executed via spring-data-neo4j: (took 8 seconds) @Query( "MATCH (user:User {uid:{0}})-[:FRIEND]-(friend:User)" + "RETURN friend" ) public List<User> getFriends(String userId); Executed via http://localhost:7474/browser/ : (took 250 ms) Executed via http://localhost:7474/webadmin/#/console/ : (took 18 ms) Even though queries executed via console are very fast and taking time under acceptable range but for

Neo4j 3.0.x PostingsFormat with name 'BlockTreeOrds' does not exist

馋奶兔 提交于 2020-01-05 02:46:13
问题 I tried updating from Neo4j 2.3 to 3.0.1. I can start up the database as a service, no problem there. But when I try to build a Neo4j executable and run it, I find a bug which I cannot resolve. Under Neo4j 2.x I can build executables fine. Below is my main method: public class StartDB { public static void main(String[] args) { new GraphDatabaseFactory() .newEmbeddedDatabaseBuilder(Paths.get(args[0]).toFile()) .loadPropertiesFromFile(args[1]) .newGraphDatabase(); } } I have a simple POM with 1

create relationship and merge node in loop in neo4j

允我心安 提交于 2020-01-04 23:51:40
问题 I am trying to create a relationship in loop from both top list and bottom list .I am trying to connect the top loop with the bottom loop .I really appreciate any help.Thanks. UNWIND [{id:"1",name:"b1",year:"2010"}, {id:"2",name:"d1",year:"2011"}, {id:"3",name:"e1",year:"2013"}] as user MERGE (u:User {id: user.id, name: user.name,year:user.year}) UNWIND [{id:"21",name:"b",year:"2010"}, {id:"41",name:"d",year:"2011"}, {id:"51",name:"e",year:"2013"}] as w MERGE (y:W {id: w.id, name: w.name,year