question stringlengths 11 28.2k | answer stringlengths 26 27.7k | tag stringclasses 130
values | question_id int64 935 78.4M | score int64 10 5.49k |
|---|---|---|---|---|
I'm running a server at my office to process some files and report the results to a remote MySQL server.
The files processing takes some time and the process dies halfway through with the following error:
2006, MySQL server has gone away
I've heard about the MySQL setting, wait_timeout, but do I need to change that o... | I have encountered this a number of times and I've normally found the answer to be a very low default setting of max_allowed_packet.
Raising it in /etc/my.cnf (under [mysqld]) to 8 or 16M usually fixes it. (The default in MySql 5.7 is 4194304, which is 4MB.)
[mysqld]
max_allowed_packet=16M
Note: Just create the line ... | MySQL | 7,942,154 | 334 |
Is there a nice way in MySQL to replicate the SQL Server function ROW_NUMBER()?
For example:
SELECT
col1, col2,
ROW_NUMBER() OVER (PARTITION BY col1, col2 ORDER BY col3 DESC) AS intRow
FROM Table1
Then I could, for example, add a condition to limit intRow to 1 to get a single row with the highest col3 for ea... | There is no ranking functionality in MySQL 5.7 or below. (This is supported in MySQL v8.0+, see @LukaszSzozda's answer)
The closest you can get is to use a variable:
SELECT t.*,
@rownum := @rownum + 1 AS rank
FROM YOUR_TABLE t,
(SELECT @rownum := 0) r
so how would that work in my case? I'd need two... | MySQL | 1,895,110 | 334 |
I'm trying to manually execute SQL commands so I can access procedures in NuoDB.
I'm using Ruby on Rails and I'm using the following command:
ActiveRecord::Base.connection.execute("SQL query")
The "SQL query" could be any SQL command.
For example, I have a table called "Feedback" and when I execute the command:
Active... | The working command I'm using to execute custom SQL statements is:
results = ActiveRecord::Base.connection.execute("foo")
with "foo" being the sql statement( i.e. "SELECT * FROM table").
This command will return a set of values as a hash and put them into the results variable.
So on my rails application_controller.rb ... | NuoDB | 22,752,777 | 215 |
I have been using cypher and neo4j for a while now, and I keep running into a similar problem again and again.
I would like to be able to add a "temporary" property to a node thats exists only in the returned data and is not persisted to the Neo4j database.
For example the current problem I am working on is given an ... | You can try returning a map projection. Take a look in this example:
// Creating a sample node
CREATE (:Person {name:'Jon', id: 1})
Returning the projection with a extra boolean:
MATCH (p:Person {id:1})
WITH p, true AS has_children
RETURN p{.*, has_children:has_children}
The result:
╒═════════════════════════════... | Neo4j | 45,837,277 | 18 |
They just announced, they changed their name to Neo5j.
I always thought that 4j meant for-Java.
And as Neo4j is implemented in Java and Scala and the ~4j suffix has been highly popular (in the 90's) it never occurred to me that the 4j and now 5j is actually a version denomination.
But it seems common in database cir... | The Neo series of databases was developed in Sweden and attracted the 'j' suffix with the release of version 4 of the graph database. The 'j' is from the word 'jätteträd', literally "giant tree", and was used to indicate the huge data structures that could now be stored.
Incidentally the 'neo' portion of the name is a ... | Neo4j | 43,157,146 | 18 |
I'm new to Neo4J, and have been learning Cypher query language the past few days.
I realized I can write my query like this...
MATCH (b:Beverage)<-[:likes]-(p:Person)-[:likes]->(r:Restaurant)
WHERE b.name = 'Beer' and r.name = 'KFC'
RETURN p.name
... or like this...
MATCH (b:Beverage{name:'Beer'})<-[:likes]-(p:Person... | I'm sorry to say, but @a-rodin's reply is wrong here: both of your statements result in the very same query plan. You can verify that by prefixing the statement with EXPLAIN and comparing the query plans.
For readability I'd structure the query in question:
MATCH (p:Person)-[:likes]->(b:Beverage{name:'Beer'}),
(... | Neo4j | 32,118,750 | 18 |
I'm trying to execute following query:
MATCH (movie:Movie {title:"test"})-[r]-() DELETE movie, r
to delete a :Movie node and all its relationships. It's all good, except if the query doesn't have any relationships, it fails to MATCH the movie. I've tried with OPTIONAL MATCH, but no luck.
I'm looking for a way to DELET... | In new Neo4j versions (since 2.3 I think) you can use such syntax:
MATCH (movie:Movie {title:"test"})
DETACH DELETE movie
| Neo4j | 29,444,426 | 18 |
Using Match and Where can delete a relationship by ID.
Match ()-[r]-() Where ID(r)=1 Delete r
Is there a simpler way?
| I use
MATCH ()-[r]-() WHERE id(r)=49 DELETE r
| Neo4j | 28,185,623 | 18 |
How to write a CYPHER query that returns only those nodes that do not have labels attached to them?
I tried:
match (n:) return n
Invalid input ')': expected whitespace or a label name (line 1, column 10)
"match (n:) return n"
^
| In Neo4j < 2.3:
MATCH n
WHERE length(labels(n)) = 0
RETURN n
In Neo4j >= 2.3:
MATCH (n)
WHERE size(labels(n)) = 0
RETURN n
| Neo4j | 24,247,505 | 18 |
I'd like a query that counts how many nodes have each label in the dataset. For instance:
LabelA 100
LabelB 200
I can do this for each individual label with something like
MATCH (n:LabelA) return count(n);
But, I'd like to do it for every label in one command.
| Try something like this
MATCH (n)
RETURN count(labels(n)), labels(n);
This will return the sum of the labels in the first column and the label name in the second.
| Neo4j | 21,555,529 | 18 |
Coming from a relational database mindset, it seems odd that one only one one graph db per instance of neo4j. Is the idea that we do multiple subgraphs starting from root ?
Thanks
| The concept of "root" node is going away. There are many problems with this, most of which revolve around node density.
I believe the heart of your question is around database design, and whether it is smarter to have several graph database instances, or one instance with several subgraphs.
Really it's up to you, but ... | Neo4j | 17,392,478 | 18 |
So I looked into neo4j, and I may be using it in an upcoming project since its data model might fit my project very well. I looked through the docs but I still need an answer to this question:
Can I set relationships to be one-directional?
It seems that the neo4j people like movies so let's continue with that. If I hav... | A relationship in Neo4j always has a direction. If a relationship type's semantics do not incorporate a direction, e.g. has_met from your example, then it's best practice to apply an arbitrary direction on creation of the relationship. Querying is then done by using the "both directions" (there is no "larger/smaller th... | Neo4j | 16,876,378 | 18 |
I have been dealing with Neo4j through python's Bulbflow and now need a way to save/export subgraphs. I have seen Java and even Ruby approaches for doing this, however a simple Python approach seems to be hiding from me..
So far, I have found two potential paths:
Accessing Geoff through py2neo, but there is surprising... | I didn't know the answer until you asked, but it seems like you can just export in gml, which networkx can read. Here are a few answers that might be useful:
Neo4j export Tree
Convert Neo4j DB to XML?
https://github.com/tinkerpop/gremlin/wiki/Gremlin-Methods
Hope that helps.
| Neo4j | 15,459,615 | 18 |
I am finding Neo4j slow to add nodes and relationships/arcs/edges when using the REST API via py2neo for Python. I understand that this is due to each REST API call executing as a single self-contained transaction.
Specifically, adding a few hundred pairs of nodes with relationships between them takes a number of secon... | There are several ways to do a bulk create with py2neo, each making only a single call to the server.
Use the create method to build a number of nodes and relationships in a single batch.
Use a cypher CREATE statement.
Use the new WriteBatch class (just released this week) to manually make a batch of nodes and relatio... | Neo4j | 12,643,662 | 18 |
I'm trying to get the number of nodes of a Neo4j graph database using Python, but I don't find any method or property to do that.
Does anybody how can I get this information?
Other Python packages like NetworkX has a method to get this information.
>>> G = nx.Graph() # or DiGraph, MultiGraph, MultiDiGraph, etc
>>> G.... | Update:
Since I first wrote this, the answer has changed. The database now keeps exact counts of total nodes, as well as counts by label. Unlike most databases, this is not a heuristic, these counters are transactionally kept in sync with the rest of the datastore.
This means you can get exact node counts in O(1) time... | Neo4j | 8,159,756 | 18 |
I have some issues with APOC and Graph Algorithms plugins.
I followed the instruction to put the .jars in {NEO4j_HOME}/plugins and also change the setting in my {NEO4j_HOME}/conf/neo4j.conf
dbms.directories.data=/Users/mlo/neo4j-community-3.3.1/data
dbms.directories.plugins=/Users/mlo/neo4j-community-3.3.1/plugins
dbms... | Change these lines:
dbms.security.procedures.unrestricted=algo.*
dbms.security.procedures.unrestricted=apoc.*
to:
dbms.security.procedures.unrestricted=algo.*,apoc.*
and restart Neo4j service.
| Neo4j | 48,773,505 | 17 |
I've built and installed the "apoc" procedures according to the github page (The apoc-1.0.0-SNAPSHOT.jar file was copied into the plugins directory after the suerver was stopped, and then I started the server again) but when I try to call any of the procedures, I get an error message.
ex:
$ call apoc.help('search') ;
... | I had to manually add this line to the .neo4j.conf file:
dbms.directories.plugins=/Applications/Neo4j\ Community\ Edition.app/Contents/Resources/app/plugins
(assuming that's where you dropped the APOC jar) and then restart the server.
(It's a little confusing as there's an option in the management app to configure this... | Neo4j | 36,897,634 | 17 |
This is an extremely simple question, but reading through the docs for the first time, I can't figure out how to construct this query. Let's say I have a graph that looks like:
and additionally each person has an age associated with them.
What CYPHER query will get me a list of John's age and all the ages of the enti... | So what you need is not only friend of john, but also friends of friends. So you need to tell neo4j to recursively go deep in the graph.
This query goes 2 level deep.
MATCH (john:Person { name:"John" })-[:friend *1..2]->(friend: Person)
RETURN friend.name, friend.age;
To go n nevel deep, don't put anything i.e. *1..
O... | Neo4j | 31,079,881 | 17 |
Is there a R library that supports neo4j? I would like to construct a R graph (e.g. igraph) from neo4j or - vice versa - store a R graph in neo4j.
More precisely, I am looking for something similar to bulbflow for Python.
Update
There is a new neo4j driver for R that looks promising: http://nicolewhite.github.io/RNeo4... | This link might be helpful. I'm going to connect ne04j with R in the following days and will try first with the provided link. Hope it helps.
I tried it out and it works well. Here is the function that works:
First, install and load packages and then execute function:
install.packages('RCurl')
install.packages('RJSONIO... | Neo4j | 11,188,918 | 17 |
I'm new to Neo4J and couldn't find the answer to my question despite my hours of googling.
So far, I have been following the tutorials and now I have a basic understanding of how/when to use Neo4j. Now, I am about to start modifying my hello-world code and connect to a Neo4J server locally installed on my machine, acc... | I couldn't find any example code on the wrapper so here is what I ended up doing.
EmbeddedGraphDatabase graphDb = new EmbeddedGraphDatabase("C:\\neo4j\\data\\graph.db");
WrappingNeoServerBootstrapper srv = new WrappingNeoServerBootstrapper(graphDb);
srv.start();
try {
while (System.in.read() != 46) {
// wait un... | Neo4j | 9,386,013 | 17 |
I just started to learn Neo4j.However, I come across a problem when connecting to Neo4j at the very beginning. As the image shown, it says "The client is unauthorized due to authentication failure." Any solutions?
| For the command line, there is same situation. Give username and pass as argument. Like:
-u neo4j -p neo4j
| Neo4j | 41,855,424 | 16 |
When should I choose Neo4j’s traversal framework over Cypher?
For example, for a friend-of-a-friend query I would write a Cypher query as follows:
MATCH (p:Person {pid:'56'})-[:FRIEND*2..2]->(fof)
WHERE NOT (p)-[:FRIEND]->(fof)
RETURN fof.pid
And the corresponding Traversal implementation would require two traversal... | The key thing to remember about Cypher vs. the traversal API is that the traversal API is an imperative way of accessing a graph, and Cypher is a declarative way of accessing a graph. You can read more about that difference here but the short version is that in imperative access, you're telling the database exactly ho... | Neo4j | 28,657,178 | 16 |
I'm trying to implement the logic in Cypher where, based on a particular condition (CASE Statement), I would create some nodes and relationships; the code is as below
MATCH (g:Game)-[:PLAYER]->(u:User)-[r1:AT]->(b1:Block)-[:NEXT]->(b2:Block)
WHERE g.game_id='G222' and u.email_id = 'xyz@example.com' and b1.block_id='1... | To do conditional write operations you need to use the FOREACH trick. Using CASE you either return a one element array or a empty one. FOREACH iterates over the CASE expression and therefore conditionally executes the action. If you want an ELSE part as well you need to have a another FOREACH using the inverse conditio... | Neo4j | 27,576,427 | 16 |
I've seen a topic (Understanding Neo4j Cypher Profile keyword and execution plan) where profile keyword is mentioned.
I couldn't use it in Neo4j 2.0.0RC1 Community.
Peter wrote it's not fully implemented.
Will it ever be supported?
I mean, it could be interesting to watch the plan changes as we tune the query...
| You can still find the neo4j shell, where you can run the profile command.
Either by connecting to the running server by starting bin/neo4j-shell
Or by switching to the old web-ui in the "(i)" Info-menu on the left side and selecting the bottommost link "webadmin" -> http://localhost:7474/webadmin
Profiling information... | Neo4j | 20,628,663 | 16 |
I can't find the data directory for my Neo4j Enterprise installation. I have looked at the config files and understand that it is in the data/graph.db file.
What is the default fully qualified path of the neo4j data directory?
| The fully qualified path to the Neo4j 2.0M6 data directory on Ubuntu 12.04 is '/var/lib/neo4j/data'
The path is also shown at the bottom of the 'Database Information' panel in the Neo4j Browser.
| Neo4j | 20,083,966 | 16 |
I've been using RDBMSes since college and am really struggling with the underlying concepts of NoSQL databases...but I think their concept is really cool.
I believe I understand the following (please correct me if I'm wrong, because these play into my question here!):
NoSQL is not some formal specification; it is a co... |
I've been using RDBMSes since college and am really struggling with the underlying concepts of NoSQL databases...but I think their concept is really cool.
A graph database like Neo4j expresses a domain in terms of vertices connected to other vertices with edges. An edge contains its start and end vertex. Each verte... | Neo4j | 9,196,276 | 16 |
In neo4j, how can I index by date and search in a date range. Also for times, I would like to search between 8am and 9am in a date range as well.
| Index the dates and times as integer timestamps. Then you can easily search in an index for dates between other timestamps. You can also index the time part of the timestamp separately as another integer, allowing you to query for specific times between given dates.
Example:
The date and time to store is "2012-02-05 8:... | Neo4j | 9,138,857 | 16 |
We're currently in the process of implementing a CRM-like solution internally for a professional firm. Due to the nature of the information stored, and the varying values and keys for the information we decided to use a document storage database, as it suited the purposes perfectly (In this case we chose MongoDB).
As p... | Mike,
you should be able to store your relationship data in the graph database. Its high performance on traversing big graphs comes from locality, i.e. you don't run queries globally but rather start a a set of nodes (which equal documents in your case, which are looked up by an index. you might even store start-node-i... | Neo4j | 5,817,182 | 16 |
Suppose there is a node, Student, that has a property Name.
MATCH (s:Student) were s.Name contains "stack"
RETURN s.Name
the output should be like : stack, Stack, STACK etc
| You can make the comparison on the upper/lower case version of each, for example:
MATCH (s:Student)
WHERE toLower(s.Name) CONTAINS toLower("stack")
RETURN s.Name
| Neo4j | 45,212,213 | 15 |
Is there a way to return just an integer through cypher?
I am working with neo4j and the javascript driver. However when I do a count() I get {low: 10, high: 0}. I would like to force this to return a low integer instead of the object above. Is this possible through cypher?
Note that I don't want to do this in the neo4... |
Starting from 1.6 version of the driver it is possible to configure it to only return native numbers instead of custom Integer objects. The configuration option affects all integers returned by the driver. Enabling this option can result in a loss of precision and incorrect numeric values being returned if the databas... | Neo4j | 42,645,342 | 15 |
I execute a long running (5 mintues) Cypher query with py2neo 2.0:
graph.cypher.run(query) or result = graph.cypher.execute(query)
The query fails after ~60 sec with a Socket Error from httpstream:
ERROR:httpstream:! SocketError: timed out
The same happens when I use a Cypher transaction. This did not happen with the s... | There's currently no way to adjust the timeout for individual queries as this setting applies at a connection level and one connection can obviously be used for many queries. The socket_timeout you're using is the correct way to adjust the timeout globally though.
| Neo4j | 27,078,352 | 15 |
I'm trying to list all of the properties for a set of nodes.
Match (n:"Indicator")
return properties(n), ID(n)
I'm unsure of the syntax and couldn't find the answer in the refcard or docs.
| In Neo4j version 3.0.0 you may do:
Match (n:Indicator) return properties(n), ID(n)
To return the ID and properties of nodes.
| Neo4j | 23,066,853 | 15 |
Imagine a photo album schema w/ Users, Albums, and Photos:
User -[owns]-> Album -[contains]-> Photo
Can I do a nested collect to get Photos nested in Albums, and Albums nested in User? I'd like results similar to:
{ "users": [
{ "name": "roger dodger",
"albums": [
{ "album": "album1",
"phot... | Try this query:
MATCH (a:USER)-[:owns]->(b:ALBUM)-[:CONTAINS]->(c:PHOTO)
WITH a,b,{url: c.name} as c_photos
WITH a,{album: b.name , photos: collect(c_photos)} as b_albums
WITH {name: a.name, albums: collect(b_albums)} as a_users
RETURN {users: collect(a_users)}
Edit
To get all properties of a node you can use string r... | Neo4j | 21,896,382 | 15 |
The graph schema I have is (actors)-[:ACTED_IN]->(movies).
I know how to find actors who have worked with a particular actor as below:
MATCH (actor {name:"Tom Hanks"} )-[:ACTED_IN]->(movies)<-[:ACTED_IN]-(costars)
return distinct costars;
I know how to find all the actors who have worked in some movie:
MATCH (all_actor... | As you want to deduct the coactors from the global list of actors this is not the best graph query, here are some suggestions.
// Max de Marzi
MATCH (actor:Actor {name:"Tom Hanks"})-[:ACTED_IN]->(movie), (other:Actor)
WHERE NOT (movie)<-[:ACTED_IN]-(other)
RETURN other
// Wes Freeman
MATCH (actor:Actor {name:"Tom Hank... | Neo4j | 21,185,463 | 15 |
When you install 1.9.4 using the new Windows installer, from where does one launch the Neo4j-Shell (previously found in bin)?
| The neo4j-shell isn't currently shipping with the neo4j desktop but you can launch it by running the following command from 'C:\Program Files\Neo4j Community\' (or equivalent location:):
jre\bin\java -classpath bin\neo4j-desktop-1.9.4.jar org.neo4j.shell.StartClient
I'm not sure whether there are plans to include it i... | Neo4j | 19,255,500 | 15 |
Given a query like the following:
START n = node(123)
MATCH p = n-[r:LIKES*..3]->x
RETURN p;
The result paths that I get with the query above contain cycles.
How can I return only simple paths?
Given this example:
How can I avoid paths with repeated nodes like: [Neo, Morpheus, Trinity, Morpheus, Neo]
| Specifying the uniqueness of paths is a planned feature of cypher.
So right now we have to ascertain that no node is a duplicate in the path.
There is an ALL predicate that must hold true for all elements of a collection (which a path is).
And with filter you can extract the elements of an collection for that a certain... | Neo4j | 13,767,748 | 15 |
I'm curious about naming conventions in neo4j.
I noticed in their examples that relationship names where capitalized, e.g.
left-[r:KNOWS]->right
Is that the convention? Is neo4j case sensitive in relationship names? Are there other naming conventions around index names and property names?
| That is the convention. I personally use lower case relationship types, and yes, it is case-sensitive. With underscores.
Usually, people use underscores for index names as well, and they're usually lower case, and also case-sensitive.
Also, something to remember: if you don't specify direction while creating, the defau... | Neo4j | 13,483,487 | 15 |
I have a simple setup and encountered a puzzling (at least for me) problem:
I have three pojos which are related to each other:
@NodeEntity
public class Unit {
@GraphId Long nodeId;
@Indexed int type;
String description;
}
@NodeEntity
public class User {
@GraphId Long nodeId;
@RelatedTo(type="user... | Found the answer to all the questions myself:
@Iterable: yes, iterable can be used for readonly
@load on access: per default nothing is loaded. and automatic lazy loading is not available (at least as far as I can gather)
For the rest:
When I need a relationship I either have to use @Fetch or use the neo4jtemplate.fetc... | Neo4j | 8,852,491 | 15 |
I'm starting on a new project that has some hierarchical data and I'm looking at all the options for storing that in a database at the moment.
I am using PostgreSQL, which does allow recursive querying. I also looked into design patterns for relational databases, such as closure tables and I had a look at graph databa... | The whole closure table is redundant if you can use recursive queries :)
I think it's much better to have a complicated recursive query that you have to figure out once than deal with the extra IO (and disk space) of a separate table and associated triggers.
I have done some simple tests with recursive queries in postg... | Neo4j | 7,497,812 | 15 |
I have found that relational databases are a very good fit for Clojure as the set functions (project/join/union etc) map very nicely to a database schema making Clojure almost a perfect fit for using with databases.
I was wondering how Clojure fits in with graph databases like Neo4j however?
| Neo4J has clojure'ey bindings here and here and here
you can get the leiningen and maven config for each of these from clojars
allegrograph is another similar graph data store that is widely supported in clojure. so there is some evidence that the answer may be yes!
graph stores lend them selves well to immutable trees... | Neo4j | 5,680,976 | 15 |
I want to translate a SQL query to cypher. Please, is there any solution to make GROUP BY in cypher?
SELECT dt.d_year,
item.i_brand_id brand_id,
item.i_brand brand,
Sum(ss_ext_discount_amt) sum_agg
FROM date_dim dt,
store_sales,
item
WHERE... | In Cypher, GROUP BY is done implicitly by all of the aggregate functions. In a WITH/RETURN statement, any columns not part of an aggregate will be the GROUP BY key.
So for example in
MATCH (n:Person)
RETURN COUNT(n), n.name, n.age
The count will count all nodes that have the same name and age. If I instead do
MATCH (n... | Neo4j | 52,722,671 | 14 |
I'm researching graph databases for a work project. Since our data is highly connected, it appears that a graph database would be a good option for us.
One of the first graph DB options I've run into is neo4j, and for the most part, I like it. However, I have one question about neo4j to which I cannot find the answer: ... | Further to Bruno Peres' answer, if you want to run a regular server instance, Neo4j will load the entire graph into memory when resources are sufficient. This does indeed improve performance.
The Manual has a chapter on configuring memory.
The page cache portion holds graph data and indexes - this is configured via t... | Neo4j | 47,764,067 | 14 |
I'm trying out the golang-neo4j-bolt-driver package
github.com/johnnadratowski/golang-neo4j-bolt-driver
I have imported the package and am using the example way of creating a new driver:
driver := bolt.NewDriver()
i get the following:
./neo.go:5: imported and not used: "github.com/johnnadratowski/golang-neo4j-bolt-dr... | You will want to alias the name of the library
bolt "github.com/johnnadratowski/golang-neo4j-bolt-driver"
You can see this in their code examples
| Neo4j | 42,818,747 | 14 |
I have a column in a csv that looks like this:
I am using this code to test how the splitting of the dates is working:
LOAD CSV WITH HEADERS FROM
'file:///..some_csv.csv' AS line
WITH
SPLIT(line.date_of_birth, '/') AS date_of_birth
return date_of_birth;
This code block works fine and gives me what I'd expect, whi... | As @cybersam said,MERGE doesn't work well with queries where the properties are set within the scope in null. So, you can use ON CREATE and ON MATCH:
LOAD CSV WITH HEADERS FROM
'file:///..some_csv.csv' AS line
MERGE (p:Person {
subject_person_id: line.subject_person_id
})
ON CREATE SET p.date_of_birth = line.date... | Neo4j | 37,081,842 | 14 |
I want to build a social network. (E.g. Persons have other persons as friends) and I guess a graph database would do the trick better than a classic database. I would like to store attributes on the edges and on the nodes. They can be json, but I do not care if the DB understands JSON.
ArangoDB can also store documents... | Both ArangoDB and Neo4j are capable of doing the job you have in mind.
Both projects have amazing documentation and getting answers for either of them is easy. Both can be used from Java (though Neo4j can be embedded).
One thing that might help your decision making process is recognizing that many NoSQL databases solve... | Neo4j | 35,118,458 | 14 |
What is the behaviour and purpose of the new Cypher operator DETACH DELETE added in Neo4j 2.3.x?
| If you want to delete nodes, you need to delete the relationships as well. In previous versions you would need to do:
MATCH (n)
OPTIONAL MATCH (n)-[r]-()
DELETE n, r
Now you can simply say:
MATCH (n)
DETACH DELETE n
| Neo4j | 33,139,903 | 14 |
Single relationships can be excluded by types using
Match (n:Person)-[r]-(m:Person) where type(r)<>"FRIENDS" return n,r,m
Is there a way to exclude multilevel relationships with cypher?
Match (n:Person)-[r*2..4]-(h:Hobby) where type(r)<>"FRIENDS" return n,r,h
| Sure, you can do that. Like this:
Match (n:Person)-[r*2..4]-(h:Hobby)
where NONE( rel in r WHERE type(rel)="FRIENDS")
return n,r,h
Your query doesn't work because with multi-level paths, your r is a collection of relationships rather than a single one. So you can use any of the predicates on collections to do the... | Neo4j | 31,746,120 | 14 |
I have a set of nodes with a property, myproperty = "James" I want to update that property from (myproperty) to (name).
Is there any way to this with Cypher?
| Solved by myself, heres what I did:
MATCH (n:term)
SET n.name = n.label
REMOVE n.label
RETURN n
| Neo4j | 22,821,714 | 14 |
I've got a property quantity on our Product-nodes and am looking to do a cypher query that gives me all nodes with quantity = 20 ... problem is that quantity is stored as a string in neo4j. Is there a way to cast the property to integer in the cypher query?
// This fails to find the required nodes
MATCH (p:Product) WHE... | You can do it the other way round.
MATCH (p:Product) WHERE p.quantity = str(20) RETURN p;
should also work with params.
MATCH (p:Product) WHERE p.quantity = str({quantity}) RETURN p;
or even with inline property matches
MATCH (p:Product {quantity : str({quantity})}) RETURN p;
| Neo4j | 21,132,844 | 14 |
Just wondering if anyone has any information on the status of project Rassilon, Neo4j's side project which focuses on improving horizontal scalability of Neo4j?
It was first announced in January 2013 here.
I'm particularly interested in knowing more about when the graph size limitation will be removed and when sharding... | The node & relationship limits are going away in 2.1, which is the next release post 2.0 (which now has a release candidate).
Rassilon is definitely still in the mix. That said, that work is not taking precedence over things like the significant bundle of new features that are in 2.0. The reason is that Neo4j as it st... | Neo4j | 20,198,982 | 14 |
In a Neo4j database with a couple of nodes and relationships, I am trying to find out the most "popular" users (in this case: The nodes participating in most relationships):
START n=node:user('*:*')
MATCH (n)-[r]->(x)
RETURN n
ORDER BY COUNT(r) DESC
LIMIT 10
However, this query (Neo4j 1.9.2) results in the following e... | In terms of neo4j mannual, if you need to use an aggregration in your "Order by", you must include the aggregration in your "Return", so you just need to add the count(r) in your "Return" as shown below,
START n=node:user('*:*')
MATCH (n)-[r]->(x)
RETURN n, COUNT(r)
ORDER BY COUNT(r) DESC
LIMIT 10
| Neo4j | 18,329,904 | 14 |
I have the following graph as a Neo4j graph database:
activates
(80 °F)
(A)------------------------------------->(D)
| \__ _/->^
| \__ activates __/ |
| \__(50 °F) ... | START a=node({A}), d=node({D})
MATCH p=a-[r:ACTIVATES*..]-d
WHERE has(r.temperature) and r.temperature='50'
RETURN p;
substitute the values in the curved brackets (A,D) with their node IDs
update:
using function all
START a=node(1), d=node(4)
MATCH p=a-[r:ACTIVATES*..]-d
WITH head(relationships(p))as r1,p //since th... | Neo4j | 14,104,682 | 14 |
I changed the /ect file permissions on Ubuntu 12.10 so that i could edit bash.bashrc so that neo4j can see the JVM but now I am getting errors when i try run the neo4j server
I entered the code below and I managed to edit bash.bashrc but now i cant use sudo at all!
sudo chmod -R ugo+rw /ect
sudo -u neo4j /home/neo4j-... | I think i have sorted it out using this command
pkexec chmod 0440 /etc/sudoers
I can now do
sudo -s
root@ubuntu:~#
Is this a good enough solution to the problem?
| Neo4j | 13,951,700 | 14 |
When I tried to create relationship using spring code,
I am getting Transaction manager error. I am using Mysql and Neo4j database in my project. I tries different solution but not able to resolve.
org.springframework.beans.factory.NoSuchBeanDefinitionException: No
bean named 'transactionManager' available: No m... | Finally, I found the mistake:
Due to this method being named dbTransactionManager, Spring couldn't find it. I just had to change its
name to transactionManager, by changing @Bean to @Bean(name = "transactionManager"), as shown below.
@Bean(name = "transactionManager")
public PlatformTransactionManager dbTransactionMana... | Neo4j | 48,861,439 | 13 |
I have this kinds of relationships:
(:User)<-[:MENTIONS]-(:Tweet)-[:ABOUT]->(:Topic)
I would like to count all the users mentioned in the tweets regarding some topic.
With the following query
match (n:Topic)<--(t:Tweet)-[:MENTIONS]->(u:User)
where n.name='politics'
return distinct count(u)
all I get is the relations... | Try putting distinct inside count function, this way:
match (n:Topic)<-[:ABOUT]-(t:Tweet)-[:MENTIONS]->(u:User)
where n.name='politics'
return count(distinct u)
| Neo4j | 47,550,506 | 13 |
Part of my graph has the following schema:
Main part of the graph is the domain, that has some persons linked to it. Person has a unique constraint on the email property, as I also have data from other sources and this fits nicely.
A person can be an admin in my case, where he has some devices/calendars linked to him.... | This answer is based on Ian Robinson's post about time-based versioned graphs.
I don't know if this answer covers ALL the requirements of the question, but I believe that can provide some insights.
Also, I'm considering you are only interested in structural versioning (that is: you are not interested in queries about ... | Neo4j | 45,669,949 | 13 |
I have a almost 5000 nodes of Recipes and 5 nodes of Meal_Types in neo4j database. Right now there is no relationship between them. I am running CQL below:
MATCH (n) RETURN n LIMIT 100000
This is running fine, but it is returning node related to Recipes only. There may be something hidden, I mean there might be nodes r... | Since you write about "display" and "colors", I assume you're writing about the Neo4j browser.
Your query might limit its results to the first 100000, but the browser will actually display much less nodes, with a default number of 300. You can change that value using the following command in the browser:
:config initia... | Neo4j | 38,501,814 | 13 |
I have a simple Neo4j graph database that I created while trying to model something for a new application. When I run the following query, I get the nodes that I am expecting, but I also get more relationships than I bargained for:
MATCH (o:Office)-[r:REPORTS_VARIABLE_TO]->()
RETURN o,r
This is what the results look... | For the newest versions (e.g 3.2, 3.3) the "auto-complete" toggle has been moved to the browser settings and its new name is "Connected all results". If it is checked, it connects nodes with all of their relationships. Otherwise, you only see relationships which meet the filtering criteria.
| Neo4j | 38,224,897 | 13 |
We've hit an issue when upgrading from spring-boot 1.3.2 to the recently released 1.3.3.
Our application has been making use of the following dependencies, each the latest, without issue:
<neo4j.version>2.3.2</neo4j.version>
<sdn.version>4.0.0.RELEASE</sdn.version>
<sdn.rest.version>3.4.0.RELEASE</sdn.rest.... | Spring Boot is missing some dependency management for logback-core which is allowing different versions to creep in. I've opened an issue to address that.
In the meantime, you can avoid the problem by adding your own dependency management for it to your pom:
<dependencyManagement>
<dependencies>
<dependency... | Neo4j | 35,738,674 | 13 |
I am preplexed on why I am getting an issue with this Cypher statment when I have a unique constraint on the address of the location node but am using a merge which should find that if it exists and only return the id for the rest of the statment. What am I missing?
Here is my statement:
MERGE(l:Location{location_name:... | You've encountered a common misunderstanding of MERGE. MERGE merges on everything you've specified within the single MERGE clause. So the order of operations are:
Search for a :Location node with all of the properties you've specified.
If found, return the node.
If not found, create the node.
Your problem occurs at s... | Neo4j | 35,381,968 | 13 |
If I have a set of nodes with the same attributes in Neo4j, is there a way to convert the type of a certain attribute from string to int (or vice versa) for all of those nodes?
| How about
MATCH (n:Type)
WHERE <filter if required>
SET n.strProp = toInt(n.strProp)
and
MATCH (n:Type)
WHERE <filter if required>
SET n.intProp = toString(n.intProp)
| Neo4j | 35,236,519 | 13 |
I spent a week at Gremlin shell trying to compose one query to
get all incoming and outgoing vertexes, including their edges and directions. All i tried everything.
g.V("name","testname").bothE.as('both').select().back('both').bothV.as('bothV').select(){it.map()}
output i need is (just example structure ):
[v{'name':"... | There's a variety of ways to approach this. Here's a few ideas that will hopefully inspire you to an answer:
gremlin> g = TinkerGraphFactory.createTinkerGraph()
==>tinkergraph[vertices:6 edges:6]
gremlin> g.V('name'... | Neo4j | 33,676,566 | 13 |
On a fresh install of neo4j-community-2.2.4 I get the message "Invalid username or password." when submitting the login form at localhost:7474/browser with the default username neo4j and password neo4j.
I did enable org.neo4j.server.webserver.address=0.0.0.0 and dbms.security.auth_enabled=true with a server stop and s... | Since you get an authentication error on your browser request which uses the default credentials neo4j:neo4j your database has already a different password configured. To reset it to default, stop neo4j, delete data/dbms/auth and start it again. Now you can use the default pw.
| Neo4j | 32,666,453 | 13 |
I have a domain class which has a property by name "alias" which is an arraylist of strings like below:
private List<String> alias;
alias contains the following values: {"John Doe","Alex Smith","Greg Walsh"}
I'd like to be able to make a query like: "I saw Smith today" using my repository query shown below and get the... | Summary
It is sort of possible to do what you want, but the query will be horribly ugly and slow. You'd be better off using nodes and relationships instead of collection properties: it will make your queries more sensible and allows you to use a full-text index. You should also figure out what part of the 'input string... | Neo4j | 32,044,348 | 13 |
How to create unique CONSTRAINT to relationship by neo4j cypher?
| At present, there is only one kind of CONSTRAINT neo4j will let you create, and that's a UNIQUENESS constraint. That link cites what's in the internal API, and you'll notice there's only one type at present.
Here's a link on how to create a uniqueness constraint.
This lets you assert that a certain property of a node m... | Neo4j | 23,610,548 | 13 |
I am new to Neo4j. I am using v2.0.1. By default the browser application's stream (output) section only displays the ID properties of the nodes in the graph db. I have added several nodes with additional properties and relationships. When the graph is displayed in the stream window I only see default ID inside of t... | While the accepted answer is correct, it doesn't show how to do it.
Since Neo4j Browser version v2.0.1, you can click on the label name at the top of the graph, options for size, color, and caption of the nodes appear at the bottom of the graph. Change the caption option to select a different property to display in the... | Neo4j | 21,739,837 | 13 |
I am using Neo4j 2.0 version. Suppose, I have lot of records which have date as one of their fields and if we need to support lot of queries like count of records between two specific dates etc, I think that I may have tpo index all the records by Date field.
Is this correct? Then., how do I do it. All nodes of the typ... | Dates as values for properties are not directly supported. Depending on your usecase you typically store the millis since epoch (aka date.getTime()) in a long property or a string representation using a DateFormatter (when being in Java land).
The long representation is better suited if you intend to do any math operat... | Neo4j | 21,643,896 | 13 |
How should I check if two nodes have relationship with each other,in neo4j embedded database in java?
I want the syntax please or a tutorial link,I have seen neo4j website but didn't find it.
Thanks.
| Given two nodes "nodeA" and "nodeB",
gets all relationships attached to "nodeA",
rels = nodeA.getRelationships();
iterate through the collection of relationships "rels", for each relationship "rel", test whether the other end node is nodeB
rel.getOtherNode(nodeA).equals(nodeB)
if the above expression holds true for ... | Neo4j | 19,477,638 | 13 |
I have imported data using Michael Hunger's Batch Import, through which I created:-
4,612,893 nodes
14,495,063 properties
node properties are indexed.
5,300,237 relationships
{Question} Cypher queries are executing too slow almost crawling, simple traversal is taking > 5 mins to return resultset, Please let me kno... | Running this on my macbook air with little RAM and CPU with your dataset.
You will get much faster than my results with more memory mapping, GCR cache and more heap for caches. Also make sure to use parameters in your queries.
You are running into combinatorial explosion.
Every step of the path adds "times rels" eleme... | Neo4j | 17,661,902 | 13 |
Is there any update query in cypher using which we can update the property of any node or relationship ?
For e.g. I have following node and relationship:
NodeA-[r:relatedTo]-NodeB
where relatedTo is a relationship having properties like active or inactive
How can I change this property using cypher query ?
| using SET keyword in cypher query, see http://docs.neo4j.org/chunked/snapshot/query-set.html . (Since I have not came across any update query in cypher like in other RDBMS)
NodeA-[r:relatedTo]-NodeB
try to set value by : SET r.<your property name>="<desired value>"; before returning any value from start n=node(...)..... | Neo4j | 16,963,183 | 13 |
I have been trying to run this query as recommended in the neo4j google group and in other sources online:
START n = node(*)
MATCH n-[r?]-()
WHERE ID(n)>0
DELETE n, r;
in order to delete all nodes and relationships between tests. When I do so from the console, I run out of java heap space. When I do so from python (u... | The cypher statement above causes all nodes (besides the root node with ID 0) to be instantiated before deletion in one single transaction. This eats up too much memory when done with 500k nodes.
Try to limit the number of nodes to delete to something around 10k-50k, like e.g.:
START n = node(*)
MATCH n-[r?]-()
WHERE... | Neo4j | 14,690,522 | 13 |
Neo4j is a really fast and scalable graph database, it seems that it can be used on business projects and it is free, too!
At the same time, there are no RDF triple stores that work well with large data or deliver a high-speed access. And what is more, free RDF triple stores perform even worse.
So what is the advantage... | The advantage of using a triple store for RDF rather than Neo4j is that that's what they're designed for. Neo4j is pretty good for many use cases, but in my experience its performance for loading and querying RDF is well below all dedicated RDF databases.
It's a fallacy that RDF databases don't scale or are not fast... | Neo4j | 10,366,131 | 13 |
Say instead of documents I have small trees that I need to store in a Lucene index. How do I go about doing that?
An example node in the tree:
class Node
{
String data;
String type;
List<Node> children;
}
In the above node the "data" member variable is a space separated string of words, so that needs to be... | Another approach is to store a representation of the current node's location in the tree. For example, the 17th leaf of the 3rd 2nd-level node of the 1st 1st-level node of the 14th tree would be represented as 014.001.003.017.
Assuming 'treepath' is the field name of the tree location, you would query on 'treepath:014*... | Neo4j | 9,970,193 | 13 |
I'am a little bit confused about what is the best solution for my application. As I've seen so far, I have to choose between neo4j standalone (RestGraphDatabase) and an EmbeddedGraphDatabase (the RemoteGraphDatabase is not for production use yet).
Pros REST:
-> Different services can access the neo4j DB (sample: i hav... | You're correct that performance with the REST server will be less. However, you can have something like transactions with the REST server using batch operations; see http://docs.neo4j.org/chunked/milestone/rest-api-batch-ops.html. You can also build domain specific server plugins that perform your transactional logic o... | Neo4j | 8,224,523 | 13 |
A Rails 3 application running on Postgresql needs to switch to a graph database to be able to grow up. There are many of them and they all offer different kind of API, REST mostly.
I am highly inspired by talks of Emil Eifrem, CEO of NeoTechnologies, about what can be accomplished with Neo4j. I must confess, I've playe... | You can run Neo4jrb with Rails 3 on jruby 1.6, so that should not be a problem.
To run a transactional (REST) API on top of that you can easily write your own Neo4j-Server plugin/extension that could also use Neo4jrb internally but exposes an API that fits your domain and is less verbose/chatty than the fine grained Ne... | Neo4j | 5,896,288 | 13 |
Neo4j doesn't seem to allow me to store binary objects. Does this mean I must used Neo4j in conjuntion with another data store, such as the filesystem., Oracle, etc?
| Daniel already answered that it's possible to store binary objects in Neo4J.
But i would suggest you not to do so. You can do nothing interesting with binary objects in database. You cannot search them. The only thing you will achieve by storing binary objects - grow the file size of your database. Mind you, Neo4J is ... | Neo4j | 5,686,692 | 13 |
I have an application backed by Neo4j database written in python.
Does anyone know what is the best approach to unit test my application ?
I have found this can be easily done in Java with usage of ImpermanentGraphDatabase. Is there a similar approach in python ?
Any tips are appreciated.
| I'm going to say the easiest way would be to mock out Neo4j entirely.
What I like to do is to simplify your entity classes to as little pure-python functionality as possible.
Even if you're using some fancy ORM to access your data - for example in Django - I still prefer to create a pure-python class to represent my ... | Neo4j | 49,348,839 | 12 |
I had worked on relational database; but now want to learn about graph database. I came to know that these two are graph database. What is difference between these two databases. What should we prefer among them?
| One approach is to simply try to choose one database over the other. For example, you might quickly search around to find that Titan has been forked to JanusGraph where it is more actively maintained. In your research you may find that there are other open source graph databases as well like OrientDb, ChronoGraph, or S... | Neo4j | 45,347,593 | 12 |
I have a graph with three node types: NodeX, NodeY, and NodeZ
I have the this cypher query:
MATCH (x:NodeX)-[*]->(d)
WHERE x.Name = 'pqr'
RETURN x,d;
Here (d) may could be either NodeY or NodeZ.
I'm looking to handle different nodetypes separately. Something like:
MATCH (x:NodeX)-[*]->(d)
WHERE x.Name = 'pqr'
... | Nodes have "labels", not "types" (the latter term only applies to relationships).
To get the labels of a node, you can use the LABELS() function. So, to test if node n has the label Foo, you can do something like this in Cypher:
CASE WHEN 'Foo' IN LABELS(n) THEN ...
However, the CASE clause cannot contain a MATCH cla... | Neo4j | 44,835,575 | 12 |
I'm trying store a map or json object as a property in Neo4j, but it doesn't work.
| That's a limitation of node properties right now. You have a few workarounds to choose from.
You can turn your json object into a string and save it as a property. You can use APOC Procedures to convert JSON strings to and from Cypher map objects.
You can instead save the map properties as properties on the node, tho... | Neo4j | 44,364,282 | 12 |
Every node in my DB has a property that holds a list. I need to check whether any item in a given list is in that property.
I'm looking for a query like match (n) where any(x in n.list where x=[101,102,103]) return n - which means "check if n.list contains 101, 102, 103. If so, return n"
Is there anything like that in ... | You pretty much have the answer to your question !
Check this : https://neo4j.com/docs/cypher-manual/current/functions/predicate/#functions-any, the any predicate exists.
The only error in your query is x=[101,102,103] that you should change by x IN [101,102,103]
So the final query is :
MATCH (n)
WHERE any(x IN n.list... | Neo4j | 39,327,437 | 12 |
I have an existing live neo4j db with relationships like this...
User-[:Owner]->Item
User contains the usual properties; name, email etc.
Owner relationship has created_on property
Item has a bunch of properties about the item; title, description etc.
I want to add in a geo-location property for the Item. This will... | You own analysis is basically correct. I would go with number 4.
Here is more about why number 2 is not a good idea. Logically: the location of an item belongs in that item's node, not in a particular relationship to it. Practically: if the object changed ownership you should not have to copy its location to a new rela... | Neo4j | 36,743,819 | 12 |
A co-worker coded something like this:
match (a)-[r]->(b), (c) set c.x=y
What does the comma do? Is it just shorthand for MATCH?
| Since Cypher's ASCII-art syntax can only let you specify one linear chain of connections in a row, the comma is there, at least in part, to allow you to specify things that might branch off. For example:
MATCH (a)-->(b)<--(c), (b)-->(d)
That represents three nodes which are all connected to b (two incoming relationsh... | Neo4j | 34,089,692 | 12 |
I want to change the color of my nodes based on their properties:
Say I have many "Person" nodes. And I want those who live in New York to be red and those who live in Los Angeles to be blue. How would I write that. In cypher or in py2neo?
| The styling of nodes and relationships in Neo4j Browser is controlled by a graph style sheet (GRASS), a cousin of CSS. You can view the current style by typing :style in the browser. To edit it, you can click on nodes and relationships and pick colors and sizes, or you can view the style sheet (:style), download it, ma... | Neo4j | 33,466,999 | 12 |
I wrote the following python code to neo4j using py2neo
from py2neo import Graph
from py2neo import neo4j,Node,Relationship
sgraph = Graph()
alice = Node("person",name="alice")
bob = Node("person",name="bob")
alice_knows_bob = Relationship(alice,"KNOWS",bob)
sgraph.create(alice_knows_bob)
but i got the follow... | If you're using Neo4j 2.2, authentication for database servers is enabled by default. You need to authenticate before performing further operations. Read documentation.
from py2neo import authenticate, Graph
# set up authentication parameters
authenticate("localhost:7474", "user", "pass")
# connect to authenticated g... | Neo4j | 29,986,317 | 12 |
In Neo4j 2.1.6, I have nodes that are non-unique in respect of a certain property, inputID.
Using Cypher, how do I remove all nodes that are duplicates in terms of a given property, leaving only uniques?
I have tried the following...
MATCH (n:Input)
WITH n.inputID, collect(n) AS nodes
WHERE size(nodes) > 1
FOREACH (n i... | You're not aliasing that WITH variable. Change this:
WITH n.inputID, collect(n) AS nodes
To this:
WITH n.inputID AS inputID, collect(n) AS nodes
| Neo4j | 28,771,150 | 12 |
I am using Neo4j as my primary database. It is a nice piece of graph database that gives me very good control over connections between nodes. However, it seems to lack highly in searching full text (search feature on a website). And therefore, I am thinking of using Elasticsearch for creating search feature on my appli... | This is a bit of an opinion-based question because it doesn't have a "right" answer, so prepare for the SO no-fun hammer to come crashing down... but I've been thinking that a one-two (Elasticsearch then Neo) punch is the best way to handle this: index properties in Elasticsearch, perform a full-text search to get poss... | Neo4j | 28,094,985 | 12 |
This should be easy, I am overlooking something. I want to match a group of nodes and return all where the ID matches any of a group of given IDs. Something like this:
MATCH (b:`Band`)-[r:`something`]->(u:`SomethingElse`)
WHERE b.uuid IN ['1', '2', '3']
RETURN b
That returns the first node that matches. I want all tha... | This worked. Leaving this up in case anyone else ever wants to know how to do it.
| Neo4j | 26,185,360 | 12 |
I have a graph with approximately nine million nodes, and twelve million relationships. For each of the nodes within the graph there is a subset of properties for each respective node which forms a unique identity for the node, by Label. The graph is being updated by various data sources which augment existing nodes wi... | Just a naive approach: what if you run a MERGE and just create or update it?
Given your list of records, consider each record as a map:
{ first: "fred", last: "lake", height: 201 }
{ first: "barry", last: "smith", language: "english" }
{ first: "fred", last: "jones", language: "welsh", height: 188 }
{ first: "fred", la... | Neo4j | 25,177,788 | 12 |
I'm trying to use regular expressions in a cypher WHERE clause. I would like to match nodes in which a node's property Text contains a specific word, as a word and not part of it.
MATCH (n:) WHERE n.Text =~ '\bword\b' return n;
This query doesn't return anything although nodes containing the word "word" exist in my gr... | There were 3 problems in your query:
(n:) should be (n), since you are not specifying a label.
Back slashes must be escaped by a preceding back slash.
The regex needs to match the entire property value (I assume that your test value was fairly long).
This query should work:
MATCH (n)
WHERE n.Text =~ '.*\\bword\\b.*'
... | Neo4j | 23,834,692 | 12 |
I was reading a paper published by Neo4J (a while ago): http://dist.neo4j.org/neo-technology-introduction.pdf
and on the 2nd to last page the Drawbacks section states that Neo4J is not good for arbitrary queries.
Say I had Nodes of users with the following properties:
NAME, AGE, GENDER
And the following relationships:... | This is a general question about the nature of graph databases. Hopefully one of the neo4j devs will jump in here, but here is my understanding.
You can think of any database as being "naturally indexed" in a certain way. In a relational database, when you look up a record in storage, generally the next record is sto... | Neo4j | 22,821,269 | 12 |
I struggle to return the node with the largest value, and process that node further.
Here's how I would return a node with the largest value:
START n=node(startnode)
MATCH n-[:TYPE]-m
RETURN m
ORDER BY m.value DESC LIMIT 1
but now I am in a subquery
START n=node(somenode)
MATCH n-[:TYPE1]-q
WITH DISTINCT q
MATCH q-[:T... | Untested... let me know if it works for you:
START n=node(somenode)
MATCH n-[:TYPE1]-q // initial query
WITH DISTINCT q
MATCH q-[:TYPE2]-m
WITH q, max(m.value) as max // get max for q
MATCH q-[:TYPE2]-m
WHERE m.value = max // find the max m for each q
WITH q, m
MATCH m... | Neo4j | 17,747,114 | 12 |
Apache Giraph vs Neo4j : Are the traversal algorithms across nodes totally different in theses two graph processing systems ? If we were to traverse say a social graph using Giraph and Neo4j on data stored in single machine (not distributed) , which would perform better and Why?
| Hands down Neo4j. Giraph's graph computations run as Hadoop jobs, because they are meant to work for large distributed graphs. The overhead of managing these jobs is too large to be efficient on a small scale graph running on a pseudo-distributed single machine cluster.
Not only that, but Neo4j's specialty is traversal... | Neo4j | 17,477,619 | 12 |
A Markov chain is composed of a set of states which can transition to other states with a certain probability.
A Markov chain can be easily represented in Neo4J by creating a node for each state, a relationship for each transition, and then annotating the transition relationships with the appropriate probability.
BUT, ... | Neo4j doesn't provide the functionality you're asking for out of the box, but since you've already come as far as correctly populating your database, the traversal that you need is just a few lines of code.
I've recreated your experiment here, with a few modifications. First of all, I populate the database with a singl... | Neo4j | 16,601,236 | 12 |
I'm new to both Scala and Neo4j. I want to create a Neo4j database using Scala. Is there any resource where i can find some ready made code for creating nodes, deleting nodes, adding properties, creating indexes and etc.
Thanks.
| Actually there are several options it depends on (a) how you want to communicate with neo4j (Rest or not) (b) your runtime environment.
When your application is ok with a REST only communication and you're ok to use ANORM to access your (data). There is a promising driver that is currently good enough to do a plenty of... | Neo4j | 15,515,865 | 12 |
I am trying to retrieve a unique set of elements linked to a given graph node. I have some nodes loaded into a Neo4j graph database, which are connected using a 'TO' relationship (e.g. node 6 connects 'TO' node 7). I have been able to retrieve all paths between my start node and others linked by the 'TO' relationship ... | I'm confused about exactly the result you want (can you give an example if this isn't right?). Do you want paths or do you want nodes? If you want nodes, then maybe you just want:
start a = node(6)
match (a)-[:TO*]->(b)
return collect(distinct b);
| Neo4j | 14,345,555 | 12 |
I wonder why neo4j has a Capacity Limit on Nodes and Relationships. The limit on Nodes and Relationships is 2^35 1 which is a "little" bit more then the "normal" 2^32 integer. Common SQL Databases for example mysql stores there primary key as int(2^32) or bigint(2^64)2. Can you explain me the advantages of this decisio... | It is an artificial limit. They are going to remove it in the not-too-distant future, although I haven't heard any official ETA.
Often enough, you run into hardware limits on a single machine before you actually hit this limit.
The current option is to manually shard your graphs to different machines. Not ideal for som... | Neo4j | 12,971,786 | 12 |
I'm just getting into graph databases, and I seem to keep running into a problem deciding between using an "index node" or an "indexed property" for tracking things like "node type". Since I've no real experience thus far, I don't have any information to base the decision on and both approaches seem to be equally valid... | First, you need to ask yourself: Does the type of a vertex/node need to be indexed? I.e. do you need to retrieve vertices/nodes by their type, let's say, retrieve all 'user' vertices from the graph or do you need to answer queries that start by retrieving all vertices of a given type and then filter/process those furth... | Neo4j | 12,754,619 | 12 |
I have an object and I need to keep a history of all changes made to it. How would I implement this using neo4j?
| As with a RDBMS, it would depend on your domain and data query requirements.
Does your application require regular access to all versions of the object or usually just to the most recent, with the older versions available via the current one? An example of this could be pages on Wikipedia. As as example, let's say we h... | Neo4j | 12,707,538 | 12 |
Is there a way to iterate through every node in a neo4j database using py2neo?
My first thought was iterating through GraphDatabaseService, but that didn't work. If there isn't a way to do it with py2neo, is there another python interface that would let me?
Edit: I'm accepting @Nicholas's answer for now, but I'll updat... | I would suggest doing that with asynchronous Cypher, something like:
from py2neo import neo4j, cypher
graph_db = neo4j.GraphDatabaseService()
def handle_row(row):
node = row[0]
# do something with `node` here
cypher.execute(graph_db, "START z=node(*) RETURN z", row_handler=handle_row)... | Neo4j | 11,076,260 | 12 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.