cypher

Neo4j create nodes and relationships from pandas dataframe with py2neo

南楼画角 提交于 2020-01-12 05:33:20
问题 Getting results on a pandas dataframe from a cypher query on a Neo4j database with py2neo is really straightforward, as: >>> from pandas import DataFrame >>> DataFrame(graph.data("MATCH (a:Person) RETURN a.name, a.born LIMIT 4")) a.born a.name 0 1964 Keanu Reeves 1 1967 Carrie-Anne Moss 2 1961 Laurence Fishburne 3 1960 Hugo Weaving Now I am trying to create (or better MERGE) a set of nodes and relationships from a pandas dataframe into a Neo4j database with py2neo. Imagine I have a dataframe

Neo4j Fast way to match fuzzy text property

主宰稳场 提交于 2020-01-12 05:28:07
问题 I have a reasonable number of nodes (roughly 60,000) (:Document {title:"A title"}) Given a title, I want to find the matching node, if it exists. The problem is that the title I'm given is not consistent. That is, sometimes the beginning of a new word is Capital, sometimes it is all lower case. Sometimes Key-Words are combined with Kebab case, sometimes they are written normally as key words. To compensate for that I use apoc and the Levenshtein distance between the given title and every node

Cypher query JSON formatted result

别等时光非礼了梦想. 提交于 2020-01-12 03:37:08
问题 On the Actor/Movie demo graph, cypher returns column names in a separate array. MATCH (n:Person) RETURN n.name as Name, n.born as Born ORDER BY n.born LIMIT 5 results: { "columns" : [ "Name", "Born" ], "data" : [ [ "Max von Sydow", 1929 ], [ "Gene Hackman", 1930 ], [ "Richard Harris", 1930 ], [ "Clint Eastwood", 1930 ], [ "Mike Nichols", 1931 ] ]} Is it possible to get each node properties tagged instead? { "nodes" : [ ["Name": "Max von Sydow", "Born": 1929 ], ...] } If I return the node

Constructing a map doesn't permit indexed collection as map key?

喜夏-厌秋 提交于 2020-01-11 07:19:38
问题 So I'm trying to actually write an answer to this question which seemed like an interesting one to me. What the hell, I'll give it a shot. Here's the solution I came up with. It seems correct to me, and should yield the right result, but instead yields a cypher parse error. So the game here is to take two collections (letters and numbers) and to construct a map out of them which maps the right letter to the right number, sequentially from the two collections. My solution: with [1,2,3] as nums

neo4j finding all paths that meets a certain criteria

て烟熏妆下的殇ゞ 提交于 2020-01-10 05:24:46
问题 I am trying to model a graph to solve some connection time problem. So for example I have the following graph F1,F2 F3 F4 ST_B--------->ST2----->ST3------>ST_E F5,F6 F7 F8 ST_B-------->ST4---->ST5------>ST_E F9 ST_B-------->ST_E I model ST_B, ST2,ST3,ST4,ST5, ST_E as station (node). and F1-F9 as flt node. And each flt node has a departure time and arrival time. And the relationship is connect. Also in this case, let's assume F2 arrival time is 30mins less than F3 departure time, and F6 is

How to query multiple property values out of order in Cypher

大兔子大兔子 提交于 2020-01-07 08:12:13
问题 I have a list of product names [shirt,shoes,pants,hat,glasses] I'm trying to perform a query that will return the products using regular expression that's case insensitive and in any order as long as the value exists. I'm only able to query them in order MATCH (product:Product) WHERE product.name =~"(?i).*shirt. shoes. " RETURN product How can I query them out of order ie MATCH (product:Product) WHERE product.name=~"(?i).*hat. shirt. "? Thanks 回答1: What exactly do you want to search for with

Add a map as property in node or relationship

こ雲淡風輕ζ 提交于 2020-01-06 15:10:13
问题 Is there a way to add a map as property? I want to store address line 1, 2 etc inside the address property itself. something similar to this - RETURN {address: {firstline:"a", secondline:"b"}, name:"ABC"} However when I try this in CREATE or SET it gives me error. I tried this - create (a:Person {name: "ABC", address: {firstline:"a", secondline:"b"}}) Error - Property values can only be of primitive types or arrays thereof 回答1: It is not possible to add map as a property. You should either

Convert Neo4j query in c# using optinal match and merge

半世苍凉 提交于 2020-01-06 07:19:12
问题 Im trying to convert a Neo4j Cypher query that works in Neo4j Desktop but when im trying to use it on c# it doesn't work, can someone help me? C# query: var type = typeof(T).Name; var client = Graph.GetClient(); client.Cypher .Match("(location:Location") .Where((Location location) => location.GeoNameId == entityGiven.GeoNameId) .OptionalMatch("()-[r:HAS]->(location)") .Delete("r") .With("l") .Match("admin:" + type + ")") .Where((Admin admin) => admin.GeoNameId == geoNameId) .Merge("(admin)-[

How to do relative node ordering using Neo4J Cypher?

假装没事ソ 提交于 2020-01-06 07:16:07
问题 I'm building a Maven dependency graph using Neo4J. One of the queries I need to support is finding all nodes that depend on a particular dependency. So if C depends on B and A, and B depends on A, findByDependency(A) should return B and C. I implemented this using the following query, and it's working: MATCH (v1)-[:DEPENDS_ON]->(v2) WHERE EXISTS (v1.gav) AND v2.gav = "A" RETURN DISTINCT v1.gav However, in my example above, C also depends on B in addition to depending on A. I'd like the result

Neo4j. Dynamic query with multiple filters on nodes

我的未来我决定 提交于 2020-01-06 05:26:25
问题 I have nodes like this and I need apply filter to them { "value": "ma", "object_field_id": 2293 } { "value": 2, "object_field_id": 2294 } MATCH (:UserData {user_id:19})-[:CARD]-(c:Card)-[:FIELD_GROUP]-()-[:FIELD]-(fi:Field) WHERE fi.object_field_id IN [23,24] AND (fi.value=~('(?iu).*149.*') AND fi.value=~('(?iu).*gb.*')) RETURN c but it doesn't work with AND Where is my mistake? 回答1: Here Is Query data for to build relations and nodes: CREATE (a:UserData {user_id: 19})-[r:CARD]->(b:Card {name