neo4j

py2neo return number of nodes and relationships created

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 09:53:46
问题 I need to create a python function such that it adds nodes and relationship to a graph and returns the number of created nodes and relationships. I have added the nodes and relationship using graph.cypher.execute(). arr_len = len(dic_st[story_id]['PER']) for j in dic_st[story_id]['PER']: graph.cypher.execute("MERGE (n:PER {name:{name}})",name = j[0].upper()) #creating the nodes of PER in the story print j[0] for j in range(0,arr_len): for k in range(j+1,arr_len): graph.cypher.execute("MATCH

Neo4J | Cypher Aggregation on list of relationships

好久不见. 提交于 2019-12-11 09:51:42
问题 New to Neo4J/Cypher and here is my query: MATCH (origin:BusStop)-[bus*]->(destination:BusStop) WITH bus WHERE origin.name =~ '(?i).*Origin.*' AND destination.name =~ '(?i).*Destination.*' AND all(rel in bus where rel.day in ['Sat']) RETURN bus I'm trying to get all the possible buses between the Origin and Destination. I also want the total fare (as a sum function) in the above query. Note: The relationship has a property called fare SUM(bus.fare)). 回答1: With APOC Procedures you can sum

Neo4j Load CSV only when unique

泄露秘密 提交于 2019-12-11 09:49:01
问题 If i have csv as follows: "route_id","service_id","trip_id","trip_headsign" 4973_3, 2, 14519396, "Bf. Tostedt" 4973_3, 2, 14519395, "Bf. Tostedt" 4973_3, 1, 14519379, "Sittensen, Schule" 4973_3, 1, 14519391, "Sittensen, Bahnhofstraße" 4973_3, 2, 14519394, "Bf. Tostedt" 4973_3, 1, 14519390, "Bf. Tostedt" 4973_3, 3, 14519381, "Bf. Tostedt" 4973_3, 4, 14519392, "Bf. Tostedt" and I want to load only when trip_headsign is unique , so in above case I would only create Trip 3 times . How do i do it?

Neo4j gem - Plucking multiple nodes/relationships

随声附和 提交于 2019-12-11 09:37:20
问题 This may not be possible as it is right now but I have a query like so events = Event.as(:e).where("(( e.date_start - {current_time} )/{one_day_p}) < 1 ").users(:u, :rel).where("rel.reminded = {reminded_p}" ).params(reminded_p: false, one_day_p: one_day, current_time: time).pluck(:e,:u, :rel) The goal is to obtain the events where the start_date is less than a day away. Hypothetically I've tried to pluck the event, the user and the relationship. I need to do a different action with each. I

Creating unique relationships without creating unique nodes in neo4j

落爺英雄遲暮 提交于 2019-12-11 09:23:49
问题 I am breaking out a question I asked elsewhere into a second part. For a given node which has an id_str that is known to be in the graph, I have a list of new id_str that may or may not be in the graph. If they /are/ in the graph, I would like to create unique relationships to them. (If they are not, I want to ignore them.) My current method is quite slow. I am doing the looping part outside of Neo, using py2neo and writing the entries one at a time using a very slow filter. Originally, I was

Laravel form data not saving in neo4j graph DB

旧城冷巷雨未停 提交于 2019-12-11 09:17:24
问题 I wrote a laravel form , its screen shot is as given below: And I use neo4j for storing that form data. Here is the code: app/views/duck-form.blade.php <!doctype html> <html> <head> <title>Laravel Form Validation!</title> <!-- load bootstrap --> <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> <style> body { padding-bottom:40px; padding-top:40px; } </style> </head> <body class="container"> <div class="row"> <div class="col-sm-8 col-sm-offset-2">

Possible to create custom functions in Cypher?

こ雲淡風輕ζ 提交于 2019-12-11 09:17:23
问题 Consider the Neo4J 2.0 Cypher query MERGE (u:User {id_str:"123"}) ON CREATE SET {giant_params_string_from_twitter_api} ON MATCH SET u.lastSeen = timestamp() RETURN u Here I've downloaded the user's metadata from Twitter, and if the user doesn't exist, then I insert all of his metadata. If the user already exists, then I just modify his timestamp. The call out to Twitter API needed to retrieve the params is long and expensive (especially when you consider that I keep getting rate limited). And

Converting ExecutionResult object to json

╄→尐↘猪︶ㄣ 提交于 2019-12-11 09:15:15
问题 I need to expose a public API, and i need to convert the result of a cypher query into json. I have begun the process, but i am having problems serializing an object of type scala.collection.convert.Wrappers$SeqWrapper that gets returned when using collect() in cypher. Here is the cypher query: MATCH (orders:Orders {id:'locationrestaurant'}), (order:Order), (orders)-[:hasOrder]-(order),(order)-[:orderedProduct]->(product),(client)-[:ordered]->(order) return (order),(client), collect(product)

Get full graph that node N is a part of in neo4j

雨燕双飞 提交于 2019-12-11 09:12:15
问题 I'm trying use Cypher to get the entire graph that exists if I start at a given node in neo4j. When I say entire graph I mean all nodes and relationships that are connected to at least one other node in the graph. I've seen examples where people can get all nodes that might be connected to a given start node with a known relationship. Examples of this include this and this, but how could I do this if I do not know the relationships? Ultimately I'd like every node and relationship where I

create relationships between nodes in parallel

早过忘川 提交于 2019-12-11 09:09:39
问题 Using cypher and neo4j 2.0. Given two sets of node ids (of equal length) and a set of weights, I'd like to create a relationship between the corresponding nodes and set the weight as a property. For example if I have the following three lists: node list 1: (101, 201, 301) node list 2: (102, 202, 302) weights: (0.1, 0.6, 0.25) I would like to create the following representation 101 - knows {w : .1} - 102 201 - knows {w : .6} - 202 301 - knows {w : .25} - 302 but NOT, for example, 101 - knows -