neo4j

CREATE UNIQUE with labels and properties

北慕城南 提交于 2019-12-10 17:43:50
问题 I'm using Neo4j 2.0.0-M06. Just learning Cypher and reading the docs. In my mind this query would work, but I should be so lucky... I'm importing tweets to a mysql-database, and from there importing them to neo4j. If a tweet is already existing in the Neo4j database, it should be updated. My query: MATCH (y:Tweet:Socialmedia) WHERE HAS (y.tweet_id) AND y.tweet_id = '123' CREATE UNIQUE (n:Tweet:Socialmedia { body : 'This is a tweet', tweet_id : '123', tweet_userid : '321', tweet_username :

Neo4j 2.0: advanced queries on label-based indexes possible?

落爺英雄遲暮 提交于 2019-12-10 17:36:35
问题 Neo4j's legacy indexes offer functionality like doing Lucene queries on them, or indexing arbitrary key/value pairs. For example, if my User node looks like this: (me { FirstName: 'John', LastName: 'Doe'}) , I can put this user in a legacy index with a key of FullName , a value of 'john doe' , and I can get this user and other users whose name starts with a 'j' with this Cypher query: start withj=node:User("FullName:j*") return withj; I'm thinking of converting my legacy index based

cypher return twice for nodes that connected in bi-directional relationship

牧云@^-^@ 提交于 2019-12-10 17:25:13
问题 I have 2 nodes: (A), (B), connected by [:FRIEND] When I run the following command, start n = node(*) match (n)-[r:FRIEND]-(b) return n.name, b.name; it returns 2 rows: A, B and B, A. I wonder, how to make it return only one record, because the relationship is bidirectional, A -[:FRIEND]-B and B-[:FRIEND]-A is considered same result. Thanks. 回答1: One trick is to add a where on the IDs, so you get them in a consistent order as well: start n = node(*) match (n)-[r:FRIEND]-(b) where id(n) < id(b)

Neo4j: Create index for nodes with same property

荒凉一梦 提交于 2019-12-10 17:24:51
问题 I have a graph with many different elements but every element has a property "ID". Now i would like to CREATE INDEX ON :anyType(ID) How can i trigger the index creation for any type? 回答1: CREATE INDEX ON takes a label, and cannot be called without the label (nor can it be called with multiple labels). So you'd have to execute this for each label type. That is, you can't run: CREATE INDEX(ID) or CREATE INDEX ON:*(ID) You need to run: CREATE INDEX ON:label(ID) 来源: https://stackoverflow.com

Using variable to create relationship in cypher?

≯℡__Kan透↙ 提交于 2019-12-10 17:15:56
问题 I'm trying to create a relationship between nodes dynamically. The problem I am having is that I am unable to use a variable to specify the relationship type. For example, I have the data: { nodes: [ { "name":"Node1" }, ... ], relationships: [ { "sourceNode": "Node1", "destinationNode": "Node2", "relationshipType": "FRIEND" }, ... ] } Assume all nodes have been created. I now want to create relationships between nodes of type relationshipType . I'm trying to do this like so: WITH {json} AS

Consuming JSON in neo4j server extension

混江龙づ霸主 提交于 2019-12-10 17:13:56
问题 I'm building a Neo4j (2.2.2) unmanaged extension and I can't figure out why the following method is throwing 415: unsupported media type when I post requests with properly-formatted JSON bodies and Content-Type:application/json headers. @POST @Path("/create") @Consumes(MediaType.APPLICATION_JSON) public Response createFoo(FooBar input) { //not relevant } This is the FooBar class I want the JSON to be mapped to: @XmlRootElement public class FooBar implements Serializable { String title; public

Cypher - Remove all properties with a particular value

自作多情 提交于 2019-12-10 16:59:37
问题 I'm searching for a way to remove every property, of any node in the DB, having a specific value using Cypher. Context I got a csv bulk file from a relational table with plenty of NULL values. LOAD CSV brings them as values. Removing them (replacing them with empty '' within the csv file) resulted in the same issue (properties without values). Tried many (many) Cypher operations to discard NULL values but nothing worked. Can't find anything in the docs neither by Googling. Can this be done

How to delete multiple nodes in neo4j

[亡魂溺海] 提交于 2019-12-10 16:45:49
问题 How to delete multiple nodes, (NOT ALL) in neo4j? I have this query MATCH (n) where n.name IS NULL delete n It returns more than one node, I want to delete all those nodes(All nodes, which are mistakenly created thats why become null). The error, I am facing is javax.transaction.HeuristicRollbackException: Failed to commit transaction Transaction(11, owner:"qtp16626756-84")[STATUS_NO_TRANSACTION,Resources=1], transaction rolled back ---> javax.transaction.xa.XAException CASE 2: What to do in

How to avoid duplications return distinct nodes and the relation ship using neo4j

て烟熏妆下的殇ゞ 提交于 2019-12-10 16:44:26
问题 I would like to return for a given node-id related nodes and their relationships props For example: -> defines a bi direction relationship with property timestamp 1234->777 777->1234 1234->999 999->1234 1234->888 888->1234 1234,777,888,999 are node-ids When I execute this: final PreparedStatement ps = conn.prepareStatement("start a = node(1234) match (a)-[k:nearby*]->(b) where a<>b return DISTINCT b, k"); ResultSet rs = ps.executeQuery(); while (rs.next()) { Map result = (Map<String, Object>)

Error “Mixing specified and unspecified group belongings in a single import isn't supported” when using neo4j-import command

扶醉桌前 提交于 2019-12-10 16:42:48
问题 I'm trying to import a fair amount of data into Neo4j, which it takes too long to be imported using the LOAD CSV way. For that reason I'm trying with the neo4j-import command but I got the following error and I haven't found any information about it or what it means exactly. The error is: 2015-04-29 14:34:06.225+0000 ERROR [org.neo4j]: Error during import Mixing specified and unspecified group belongings in a single import isn't supported java.lang.RuntimeException: Mixing specified and