w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
  Home » NEO4J » Page 1
Adding existing nodes to a spatial index (using spring data)
I'm not a Spring kinda guy, but here are some answers to the general question that may be of help. Neo4j spatial cypher query withinDistance doesn't return existing nodes Neo4j Spatial, relationship between indexes and layers

Categories : Neo4j

how to find me and my followers posts in neo4j
Assuming you can uniquely identify yourself by an ID: MATCH (me:User {Id: 1})<-[:FOLLOWS*0..1]-(follower)-[:POSTED]->(post) RETURN post; Rationale: in the case where the length of the :FOLLOWS relationship is 0, me == follower, so the query returns your posts as well. You can find an example here: http://console.neo4j.org/?id=dexd4p

Categories : Neo4j

Update property value in Neo4j on import
[EDITED] You should be able to do this: LOAD CSV FROM 'file:///home/gvanjoic/file.csv' AS line MERGE (n:A {number : line[0]}) WITH line, n MERGE (m:B {ID : line[1]}) WITH m,n MERGE (n)-[rel:LIKES]->(m) ON CREATE SET rel.times = (CASE WHEN rel.times IS NULL THEN 0 ELSE rel.times END) + 1;

Categories : Neo4j

Neo4j indexing for large number of nodes
[Edited] Moving the status property from the relationship to the person node does not seem to be the right approach, since I presume the same person can be a customer of multiple merchants. Instead, you can reify the relationship as a node (let's label it purchase), as in: (:person)-[:HAS_PURCHASE]->(:purchase)-[:BOUGHT_AT]->(merchant) The purchase nodes can have the status property. Yo

Categories : Neo4j

How to add infinity, NaN, or null values to a double[] property on a node in Cypher/Neo4j
Do you actually want to have a null value in the array or would it be better to just not touch it in the null case? How about something like this where you only set p_value if the newPValue is non null? WITH null AS newPValue MERGE (process:GOTERM { name: "immune system process", go_id: 50896}) ON CREATE SET process.som = ["som_mouse_3_2"], process.p_value = [] ON MATCH SET process.som = process

Categories : Neo4j

Implement privacy settings in status updates in Neo4j database
For the sharing-level I'd set a label on the content (:SharePublic (or leave that off) :ShareFriends, :ShareGroup, :ShareIndividual) For groups and individuals create a relationship from the content. To aggregate the newsfeed for a user Until limit go over potential news items allow public allow individual if pointing to me allow group if pointing to one of my groups allow friend if friend wi

Categories : Neo4j

Nutch 2.x integration with neo4j
There are many ways of integrating with Neo4j, not sure what Nutch is written in, but for most languages there are drivers

Categories : Neo4j

neo4j collecting nodes and relations type b-->a<--c,a<--d
The most immediate problem is that the comma in the MATCH clause separates the first pattern from the second. The variable 'p' only stores the first pattern. This is why you aren't getting the results you desire. Independent of that, you are at risk of having a 'loose binding' by putting a label on both of your nodes named 'b' in the two patterns. The second 'b' node should not have a label. So h

Categories : Neo4j

Begin in cypher - get Actors acted in past 2 years
Using the data in this example: http://neo4j.com/docs/stable/cypherdoc-movie-database.html you can do things like: MATCH (actor:Actor)-[:ACTS_IN]->(actorMovies) WITH actor, collect(actorMovies.year) AS years WHERE '1999-03-31' IN years RETURN actor.name The point is to do the aggregation in the WITH clause, and then use the result in a WHERE clause afterwards. If integers are used for the y

Categories : Neo4j

neo4j and mahout comparison
This is a deep question that can't be specifically answered without a lot more information about what kind of recommendation system you want, what kind of scalability you need, what your hardware/software/platform configuration looks like, and so on. But let me give you this to consider: the issue isn't a comparison of neo4j and mahout, it's a comparison between neo4j and hadoop. Mahout would

Categories : Neo4j

How to load all related node without includeing them in cypher in noe4jclinet
Make sure to have indexes for :User(UserName) and :HashTag(Value) You create a cross product here, not sure that you want this, probably a union is better You can just expand the pattern to contain other relationships off :Post too. MATCH (o)-[r]-(post:Post)-[:HAS_MentionedUsers]->(assignee1307989068:User), WHERE (assignee1307989068.UserName = "mhs") RETURN post,o,r UNION MATCH (o)-[r]-(post

Categories : Neo4j

Do spring data neo4j repositories not distinguish types?
There is a typesafety strategy/policy in SDN for controlling that behavior: <bean id="typeSafetyPolicy" class="org.springframework.data.neo4j.support.typesafety.TypeSafetyPolicy"> <constructor-arg type="org.springframework.data.neo4j.support.typesafety.TypeSafetyOption"><value>RETURNS_NULL</value></constructor-arg> </bean> or @Bean TypeSafetyPolicy type

Categories : Neo4j

Loading CSV and retrieving from it at the same time
Not sure about the match of the last_name = GUINNESS with the load operation. I would be tempted to wait until after the data was loaded. That might have the effect of loading nothing at all if the database is empty already. I would set your files setting to this though file:///C:/CSV/actor.csv.

Categories : Neo4j

How to programmatically query Neo4J auto index (as opposed to legacy index)
You can use the GraphDatabaseService#findNodesByLabelAndProperty method (available on your db val). There's good documentation example of this here: http://neo4j.com/docs/stable/tutorials-java-embedded-new-index.html

Categories : Neo4j

Neo4j cluster - "UnableToSampleException" when neo4j node starts, that was master before crash
The root exception is not being logged. You have to debug the NodeIdsInUseSampleable class. In my case i got the following exception: java.lang.IllegalStateException: XaDataSourceManager has been shut down. at org.neo4j.kernel.impl.transaction.XaDataSourceManager.getXaDataSource(XaDataSourceManager.java:211) at org.neo4j.kernel.impl.transaction.XaDataSourceManager.getNeoStoreDataSource(Xa

Categories : Neo4j

neo4j batch importer NumberFormatException
Don't use that one, use the normal github.com/jexp/batch-import for 2.1 or wait for 2.2 milestone for something out of the box. The superfast is not production ready and was known to create inconsistent stores.

Categories : Neo4j

Neo4J Write: CPU at 100% when there is a lot of write
Your trace looks ok, it is just a few threads busy reading things. It could be garbage collection induced CPU spikes or something else that's not visible in the stacks. Can you share the (type of) statements you run? For your queries: only merge on one label make sure to have an index / constraint for each :Label(property) that you merge or match on if you match on a property always have a :L

Categories : Neo4j

get all transitive relationships from a node via cypher
You need to use a variable path match, assuming your start node is node 1 having label Label and name='node1': MATCH path=(node1:Label {name:'node1'})-[*..100]->() RETURN relationships(path) as rels The relationships function returns a list holding all relationships along that path. It is a best practice to provide an upper limit to variable depth matches, here I've set it arbitrarily to 100

Categories : Neo4j

Neo4j shell connect to local server
It seems the shell doesn't try to connect localhost but your external IP address? Perhaps something wrong with the IP resolution? (/etc/hosts or DNS). You can provide a -host 127.0.0.1 parameter to the shell, perhaps that helps?

Categories : Neo4j

Neo4j merge performance
Yes there are a couple of things you can do : What is your indexing strategy ? Do you have the SocialProfile-profile_id property indexed ? Use query parameters, so the cypher query can be cached independtly of the passed parameters for the first match, you can match first the socialprofile alone, using label+indexed property profile_id and then match the pattern to user : MATCH (profile:Socia

Categories : Neo4j

Is it possible to run a Neo4j cluster with strong consistency?
There is such an config option. ha.tx_push_factor determines to how many slaves a transaction should be pushed to synchronously. When setting this to ha.tx_push_factor=<clustersize>-1 you have immediate full consistency.

Categories : Neo4j

Use first relationship in query path to filter the rest of the path relationships - Neo4j
Unfortunately you cannot parameterise the type of the relationship so the query has to be a little more complicated. You can start with something like this: MATCH (a:Node)-[r]-(b:Node) WITH a, r, TYPE(r) AS type, b MATCH path=b-[rr*]-c WHERE ALL (rrtype IN RELATIONSHIPS(path) WHERE type = TYPE(rrtype)) RETURN a, r, path This query matches your relationship from a to b and uses a WITH o

Categories : Neo4j

Cypher FOREACH MERGE not hitting the index
Hmmm, does it use an index if you use UNWIND instead of FOREACH? MERGE (p:Person {pid: {personId}}) ON CREATE SET p.value=rand() MERGE (c:Page {url: {pageUrl}}) ON CREATE SET c.value=rand() MERGE p-[:REL]->c WITH c UNWIND {tags} AS tagValue MERGE (t:Tag {value:tagValue}) MERGE c-[:hasTag]->t

Categories : Neo4j

Neo4j Converting Boolean to an Int
You can do CASE WHEN a.name = b.name THEN 1 ELSE 0 END (and do sum on that, or something). However, you might have dups if you're doing distinct of the other two--maybe you need to adjust something in the rest of your query to avoid duplicates, if you can give us more detail.

Categories : Neo4j

Fast way to mockup hierarchical data easily
There is an online tool capable of generating graphs : http://graphgen.neoxygen.io It is based on the Cypher spec. A simple pattern expressing Deptartment Org Chart, could be defined like this : (Dept1:Department {name:word}*5)<-[:PART_OF *1..n]-(subDept1:Department {name:word} *10) (Dept2:Department {name:word} *5)<-[:PART_OF *1..n]-(subDept2:Department {name:word} *10) (ssd1:Department

Categories : Neo4j

Deleting nodes also deletes relationships when using spring-data-neo4j, which is different from the cypher default
I think that the SDN repository delete methods are more akin to: MATCH (j:Juntion) OPTIONAL MATCH (j)-[r]-() DELETE r, j For me that is exactly what I want but if you want a different behaviour you could override the delete method in your junctionRepository interface like this: @Override @Query("MATCH (j:Junction) WHERE ID(j)={0} DELETE j") public void delete(Long id); Now if you try to dele

Categories : Neo4j

Neo4j Cypher: String Build with Unwind and Array
Ideally you would use the ll identifier in your query. However by seeing you have a property named Label, I remind you that currently it is not possible to add labels dynamically. A possible query you might do is : UNWIND MyList AS ll CREATE (user:User) SET user.lang = {ll}.Lang Chris

Categories : Neo4j

neo4jphp: Cypher and Resultset differ
I think you get doubles because you have multiple paths (e.g. multiple teams) for the user, use RETURN distinct user For your import statement, you do it the wrong way round, instead of your approach. MERGE by unique id (e.g login in your case) and set the other properties with ON CREATE SET ... Also use parameters not literal values in your query strings !! MERGE (user:PERSON {login:{login}

Categories : Neo4j

Neo4j server plugin basic questions
How to create a unique node i.e. guarantee uniqueness of a property? You can create a unique constraint on a (label, property) pair which will ensure the uniqueness of that property. e.g. CREATE UNIQUE CONSTRAINT ON :Person(name) Would ensure you can't have two people nodes with the same name. If you want to do that from the Java API you'd do something like this: try ( Transaction tx = g

Categories : Neo4j

How to fetch nodes with different labels in one query in Neo4j
Try to separate the different parts of your query using WITH: MATCH (meal:Meal) OPTIONAL MATCH (meal)<-[:JOIN]-(user:User) WITH meal, collect(ID(user)) as users OPTIONAL MATCH (meal)<-[:ORDERED]-(dish:Dish) RETURN id(meal), meal.name, users, COLLECT(ID(dish)) as dishes

Categories : Neo4j

Creating time-based ('After', 'Before') relationships in Neo4j
I think if you want to create an ordering between a specific person's attendance at an event then you need to introduce the concept of their attendance e.g. (:Person)-[:ATTENDED]->(:Attendance)-[:EVENT]->(:Event) Otherwise if you just have the 'AT' relationship then there isn't a way to order those as you can't create a relationship between relationships. So assuming you have the concept

Categories : Neo4j

Returning only the first common node
You need to do an aggregation on level of friend using the collect function: MATCH (joe { name: 'Joe' })-[:knows]-(friend)-[:knows]-(friend_of_friend) WHERE NOT (joe)-[:knows]-(friend_of_friend) RETURN friend.name, collect(friend_of_friend.name) update MATCH path=(joe { name: 'Joe' })-[:knows]-(friend)-[:knows]-(friend_of_friend) WHERE NOT (joe)-[:knows]-(friend_of_friend) RETURN collect(f

Categories : Neo4j

How to retrieve nodes for multiple depth relationships Neo4j Database Cypher?
Assuming you just mistyped the query, what isn't working? MATCH (:City{name:'Gotham'})<--(bank:Bank) RETURN bank should work fine. Completely wrong as typed, should have read (the lonely star indicating, all relationships of any type, any length path): MATCH (:City{name:'Gotham'})<-[*]-(bank:Bank) RETURN bank Better would be: MATCH (:City{name:'Gotham'})<-[:LOCATED*1..2]-(bank:B

Categories : Neo4j

Graph Model: How to mark items in Neo4J as Read/Viewed
[EDITED] Here is one approach. When creating new Message nodes, assign false to a wasRead property on the HAS_MESSAGE relationship. Then, when you want to get unread messages (and, at the same time, mark them as having been read): MATCH (user:Person)-[r:HAS_MESSAGE]->(message:Message) WHERE user.EmployeeId = 'XYZ123' AND r.wasRead = false SET r.wasRead = true RETURN message For better perf

Categories : Neo4j

Fetching specific paths from neo4j Graph database
First, A simple solution is to follow the LOAD CSV query with others that clean up your graph. Run the queries MATCH (zip:Zipcode { Code : ''})<-[r]-() DELETE zip, r and MATCH (c:Country { Name : ''})<-[r]-() DELETE c, r You will then have the graph you desire.

Categories : Neo4j

sigma.js / Spring Data Rest / Neo4j - right design?
Yes, a custom rest controller for the JSON format you expect would make sense, see our example here (it is for d3 but you get the idea): http://neo4j.com/developer/java/#_using_spring_data_neo4j There is also a linked github repository with the code.

Categories : Neo4j

Neo4j Community Windows JMX monitoring
If you open the service dashboard app there's a settings button where you can edit the config files. If you can't find what you need there, you can download the zip instead of the installer, and that should have a full conf folder.

Categories : Neo4j

Embedded neo4j server and web admin at the same time
Here's what I've been using (on 2.1.3, hopefully works the same on 2.1.5)- WrappingNeoServerBootstrapper neoServerBootstrapper; GraphDatabaseService db = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder("/path/to/db").newGraphDatabase(); registerShutdownHook(db); try { GraphDatabaseAPI api = (GraphDatabaseAPI) db; ServerConfigurator config = new ServerConfigurator(api); config.c

Categories : Neo4j

Neo4j Spatial - Find the intersection of a polygon and a line
If you application is written in Java with the embedded API, then Neo4j Spatial has all the tools you need because it makes use of JTS internally and so you can perform any JTS query you want. However, to benefit from the RTree index to make the query fast will require that you also limit the search scope somewhat. If you have an idea of a maximum distance you wish to search you could solve this i

Categories : Neo4j




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.