cypher

Short incremental uinque id for neo4j

人走茶凉 提交于 2020-01-24 23:09:53
问题 I use django with neo4j as database. I need to use short url based on node ids in my rest api. In neo4j there is an id used in database that didn't recommended to use in app, and there is approach to use uuid that is too long for my short urls. So I add my uid generator: def uid_generator(): last_id = db.cypher_query("MATCH (n) RETURN count(*) AS lastId")[0][0][0] if last_id is None: last_id = 0 last_id = str(last_id) hash = sha256() hash.update(str(time.time()).encode()) return hash

cypher 2.0 : using label based index to search a set of nodes

喜夏-厌秋 提交于 2020-01-24 13:09:08
问题 I have users and groups they belong to. I have an index n:Group(name) I want to search for all users belong to a set of groups : ["gr1","gr2","gr3"] which other groups they belong to. so I have the following query: Query : MATCH (gr:Group) <--(us:User)--(gr2:Group) WHERE gr.name in ["gr1","gr2"] return distinct gr2 The thing here, is that I think that cypher don't use the index because the query is to slow. I have 2k nodes, 50k relationships. The following query takes between 200 to 700 ms

Neo4J ClientError.Statement.SyntaxError

混江龙づ霸主 提交于 2020-01-23 12:59:09
问题 I am getting Neo.ClientError.Statement.SyntaxError while loading data from CSV file. Neo.ClientError.Statement.SyntaxError: Invalid input 'h': expected 'i/I' (line 5, column 3 (offset: 189)) "Merge (Zip_Code:Zip_Code {code: row.zip_cd,type:'location'})" Here is my Query: Using Periodic Commit LOAD CSV WITH HEADERS FROM "file:///DOL_data_whd_whisard_reduced.csv" AS row Merge (State_Code:State_Code {code: row.st_cd}) where not row.st_cd is null Merge (Zip_Code:Zip_Code {code: row.zip_cd,type:

Neo4j cypher to count and display all the relationship between two given nodes

筅森魡賤 提交于 2020-01-23 07:57:43
问题 Here I am using neo4j rest api, in first step I want to collect information like how many relationships are there between two given nodes. Sample : MATCH (n:Node {id: {parameter1}})-[r:someType]-(m:Node {id: {parameter2}}) RETURN COUNT(r) Then I would like to collect all the values assigned to the edges so I can calculate further calculations. I need all the different types of relationships and their properties between two given nodes. If it is possible I would like to do it in single cypher.

Neo4j cypher to count and display all the relationship between two given nodes

僤鯓⒐⒋嵵緔 提交于 2020-01-23 07:57:08
问题 Here I am using neo4j rest api, in first step I want to collect information like how many relationships are there between two given nodes. Sample : MATCH (n:Node {id: {parameter1}})-[r:someType]-(m:Node {id: {parameter2}}) RETURN COUNT(r) Then I would like to collect all the values assigned to the edges so I can calculate further calculations. I need all the different types of relationships and their properties between two given nodes. If it is possible I would like to do it in single cypher.

Neo4j: Match multiple labels (2 or more)

蓝咒 提交于 2020-01-19 06:53:32
问题 I would like to do a search, and I would like to start traversing from 2 labels (OR condition). For example, I need to find out all the nodes which have labels either 'Male' or 'Female' and whose property, name =~ '. ail. '. 回答1: You can put this condition in the WHERE clause: MATCH (n) WHERE n:Male OR n:Female RETURN n EDIT As @tbaum points out this performs an AllNodesScan . I wrote the answer when labels were fairly new and expected the query planner to eventually implement it with a

How to filters data at node level in Neo4j Cypher

怎甘沉沦 提交于 2020-01-17 08:16:06
问题 Let suppose we have two match and now we want something like that (match1-match2) match (u:User)-[r:HAS_RESOURCES]-(resource:Resource) where id(u)=1484 match (resource1:Resource)-[r1:OWNED_BY_USER]-(owner:User) where resource1.isPublished=true return resource1 This cypher we made . So now we want something like this id(resource1)-id(resource) 回答1: you can filter resources that are not in a collection. Make sure to have an index on :Resource(isPublished) otherwise you have to scan across all

Neo4j 2.0 How Long can a Cypher Query Be when Passed to the Execution Engine?

非 Y 不嫁゛ 提交于 2020-01-17 06:20:13
问题 Basically, what's the limit on query size? I'm writing a query that searches all properties in the database for a string. At the end of the query, I take the results and sort them into buckets. This makes for a very long cypher query. I'm passing this query to the Execution Engine in a server plug-in. Right now I have a limited amount of properties, so the query runs fine. I'm just concerned that as I get more properties over time that the actual string size of the query will be too long for

create relationships in neo4j cypher using case statement

微笑、不失礼 提交于 2020-01-17 05:50:31
问题 I have a JSON in the next form: { "conditions": [ { "id": "123", "type": "a", entities: ["529", "454"] }, { "id": "124", "type": "b", entities: ["530", "455"] } ] } I want to create relation ship between the Condition node with node A Entities or node B entities based on type attribute which can be A/B i Assuming that these entities already exists in neo4j. I am trying something like the below cypher but that doesn't work. WITH {json} as data UNWIND data.conditions as condition MATCH (c

Collecting the result of cypher query into a hash map java?

社会主义新天地 提交于 2020-01-17 03:29:31
问题 This is a followup of Finding connected nodes question. The code is firstNode = graphDb.createNode();//creating nodes firstNode.setProperty( "person", "Andy " ); Label myLabel = DynamicLabel.label("person"); firstNode.addLabel(myLabel); ... relationship = firstNode.createRelationshipTo( secondNode, RelTypes.emails );// creating relationships relationship.setProperty( "relationship", "email " );.... ExecutionEngine engine = new ExecutionEngine(graphDb); ExecutionResult result = engine.execute(