cypher

cypher union group by sum

别说谁变了你拦得住时间么 提交于 2019-12-13 21:26:09
问题 I would like to boost edges for a user depending of some rules base on graph traversal. Basically in mysql I would do that : select id, sum(weight) as total from ( select id, 10 as weight from user inner join userRel1 ON user.id = userRel1.userId where userRel1.attr1 in (1, 2) union select id, 5 as weight from user inner join userRel2 ON user.id = userRel2.userId inner join userRel3 ON user.id = userRel3.userId where userRel2.attr2 = 'a' and userRel3.attr2 = 'z' union ... ) group by id order

How to return all properties of a node with their name and their value using Cypher

北慕城南 提交于 2019-12-13 18:19:26
问题 I saw here : How can I return all properties for a node using Cypher? that somebody already asked this question, but 1 year ago. So i need to ask it now : is there a way, today, to return all properties of a node using cypher? i need to do it for a translation system where previous developpers have created it as 1 node per language, with contains all of the properties with their name in the desired language. I need to get it for a Java application. Example: node FR contains: "Salut_01" :

Optimize Neo4j Cypher path finding with limited paths in an undirected graph

一世执手 提交于 2019-12-13 17:23:31
问题 As a follow-up from the question "Neo4j Cypher path finding slow in undirected graph". Michael Hunger and Wes Freeman kindly helped but I failed to adapt the techniques learned to path finding queries that should return the paths. The issue: The below query takes roughly 3s and returns 13 rows (the paths found) from a database. I find it slow and would like to have it execute faster but don't know how to optimize it. (This is an example of course but I find similar other queries slow too.)

Neo4j CSV file load with empty cells

蓝咒 提交于 2019-12-13 17:07:44
问题 I am loading a basic CSV file into Neo4j database which has got two columns - "name" and "property". The name column always has a value and "property" column can either have a value or a blank space. I would like to values to be linked with a relationship "property1". I am using this code: LOAD CSV WITH HEADERS FROM 'file:///fileName.csv' AS line MERGE (Test_Document:A {name: line.name}) WITH line, Test_Document FOREACH (x IN CASE WHEN line.property IS NULL THEN [] ELSE [1] END | MERGE

How to query property value when property name is a parameter?

自古美人都是妖i 提交于 2019-12-13 15:26:47
问题 Typically we can query property value for something like: Match (n:Product) where n.name="iPhone X" return n However, in my case, I don't know which property I should match, but I only know the value, in which case the property name becomes a kind of variable. I want something like this: Match (n:Product) where n.{name}="iPhone X" return n or with relationship variable r: Match (n:Product)-[{r}]->(c:Color {name:'white'}) In both cases, in my application I know some property or relationship

neo4j - user suggestion with mutual count

纵然是瞬间 提交于 2019-12-13 08:14:56
问题 I have created 5 nodes in neo4j as follows. Node 1 {userid:1000, username: A, someOtherProperties...} Node 2 {userid:2000, username: B, someOtherProperties...} Node 3 {userid:3000, username: c, someOtherProperties...} Node 4 {userid:4000, username: D, someOtherProperties...} Node 5 {userid:5000, username: E, someOtherProperties...} Node 1 connected with Node 2 & 3, and Node 2 connected with node 1, 3, 4 1 -> 2 1 -> 3 2 -> 1 2 -> 3 2 -> 4 3 -> 4 Now I want user suggestion for node 1 which

How to integrate Neo4j database, NestJS framework and GraphQL?

匆匆过客 提交于 2019-12-13 07:53:58
问题 I'm trying to integrate my REST API (NestJS) with new Neo4j database with GraphQL queries. Anybody succeed? Thanks in advance EDIT 1: (I added my code) import { Resolver } from "@nestjs/graphql"; import { Query, forwardRef, Inject, Logger } from "@nestjs/common"; import { Neo4jService } from "src/shared/neo4j/neoj4.service"; import { GraphModelService } from "./models/model.service"; import { Movie } from "src/graphql.schema"; @Resolver('Movie') export class GraphService { constructor(private

How can I copy a path in Neo4j?

廉价感情. 提交于 2019-12-13 07:12:43
问题 I'd like to recreate a whole chain of nodes and relationships in Neo4j. I know that I can save a path with p= , but CREATE doesn't accept this. MATCH p=(:Person)-[*]->(:Dog) CREATE p Is there a way to do this? 回答1: As you've seen, the syntax you tried does not work, so one would have to attempt to write a lot of Cypher code to copy all the parts of each path. However, it turns out that it is not currently possible to use Cypher alone to duplicate arbitrary paths -- as some needed capabilities

Neo4j how to get first 10 desc codes

天大地大妈咪最大 提交于 2019-12-13 07:00:26
问题 I have this relation MATCH (chatitems)-[r:PartOf]->(teams)-[o:OwnedBy]-() I want to get teams.id and chatitems.id from first 10 teams distinct and ordered desc. I need to keep teams.id and chatitems because I need to use in other match I executed two queries first is MATCH (chatitems)-[r:PartOf]->(teams)-[o:OwnedBy]-() with distinct teams order by teams.id DESC with collect(teams)[0..10] as teams1 unwind teams1 as teamsid return teamsid Results are teamsid "{""id"":62531}" "{""id"":58852}" "{

Neo4j : Slow Selection Operation with Huge Data

一曲冷凌霜 提交于 2019-12-13 06:46:28
问题 I am trying to the nodes from the Graph randomly each time. the number of nodes is 24600968 in the database. The following query MATCH (n:Employee) WITH n AS emp,rand() AS ids ORDER BY ids LIMIT 10 MATCH (n:Company) WITH emp, n AS com,rand() AS ids ORDER BY ids LIMIT 10 RETURN emp.guid,com.guid is taking very long time. The time is Returned 10 rows in 306863 ms. How can I speed up this process. 回答1: run 2 separate statements try this Lookup nodes by a random set of ids and check if they are