Re: [Neo4j] Cypher - variable length relationships that *aren't* of a type
Andrés, You are not the first one to run into this. "g" is an iterable of > relationships, and not a single relationship. Maybe we should make this a > valid query... > > Anyway, with Cypher as it works today, you have to do this: > START a = node(2) > MATCH p = (a -[g*0..5]->b) > WHERE ALL(r in g WHERE not(type(r) ="INSTANCE") > RETURN p > > Thinking about this, it would be trivial to translate your query to this > query under the hood. WDYT? Thanks for the quick response! My only concern about translating the query is that it could prevent moments like this- if the query had "just worked" I would have continued to misunderstand 'g' as a collection. Maybe a few function aliases, like `ALL_OF_TYPE(g, 'INSTANCE')`, `NONE_OF_TYPE(g, 'INSTANCE')`, etc would make sense? They serve the same purpose, are easily discoverable in docs, and make it really clear that multi-hop relation identifiers refer to collections. > Then I realized that even if it were, this statement would still traverse > > across the reference node (potentially hitting supernodes in the > > type hierarchy) because where clauses are evaluated after traversals. > > > > No, the pattern matcher evaluates predicates as soon as the necessary parts > have been found, with a few exceptions. Filtering after the fact would be > much more expensive. I think the very first version of Cypher did do this, > but it's been changed for quite some time now. Ah! I saw some mention of subgraph generation and filtering being separate. I thought that was pretty dumb, but with all the talk about Cypher's mediocre performance I was worried it was true. Thanks for educating me! -- Matt Luongo Co-Founder, Scholr.ly ___ NOTICE: THIS MAILING LIST IS BEING SWITCHED TO GOOGLE GROUPS, please register and consider posting at https://groups.google.com/forum/#!forum/neo4j Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
[Neo4j] Cypher - variable length relationships that *aren't* of a type
Hey everybody, I'm trying to write a query that returns a small subgraph around a type system's sub-reference node, excluding relationships used to define the in-graph type hierarchy. Eg, given a graph (0)-[:TYPE]->(1)-[:INSTANCE]->(2)-[:SOMETYPE1]->(3) (2)-[:SOMETYPE2]->(4)-[:SOMETYPE5]->(5)-[:SOMETYPE6]->(6) (7)-[:SOMETYPE7]->(2) I'd like to get all paths from length 0 to 5 from node (2), excluding those that start with the 'INSTANCE' relationship type. I started with `START a = node(2) MATCH p = (a -[g*0..5]->b) WHERE not(type(g) = "INSTANCE") RETURN p`, which doesn't seem to be valid. Then I realized that even if it were, this statement would still traverse across the reference node (potentially hitting supernodes in the type hierarchy) because where clauses are evaluated after traversals. Is there a way to accomplish what I need in the match clause? Basically, some way to say "any relationship but these types, path length 0-5". Thanks! -- Matt Luongo Co-Founder, Scholr.ly ___ NOTICE: THIS MAILING LIST IS BEING SWITCHED TO GOOGLE GROUPS, please register and consider posting at https://groups.google.com/forum/#!forum/neo4j Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] [Neo4j-User] Re: Unique constraint and transaction over REST
Haha, looking forward to hearing your thoughts. -- Matt Luongo Co-Founder, Scholr.ly On Mon, Dec 5, 2011 at 7:10 PM, Marko Rodriguez wrote: > > > We have an alpha release coming up- would you be interested in seeing > what > > we have? > > Oh would I! Golly gee. > > :P, > Marko. > > http://markorodriguez.com > ___ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] Unique constraint and transaction over REST
Marko, Thanks for the link, it's obviously very relevant to what we're doing! We've talked a ton about trying to solve some of the problems it looks like k-reef was designed to, but weren't quite ambitious enough :) We have an alpha release coming up- would you be interested in seeing what we have? -- Matt Luongo Co-Founder, Scholr.ly On Mon, Dec 5, 2011 at 12:30 PM, Marko Rodriguez wrote: > Hey, > > Matt: This isn't related to this thread, but I noticed you are from > Scholar.ly. I thought you might like this: > >http://arxiv.org/abs/0905.1594 > > Go Canucks!, > Marko. > > http://markorodriguez.com > > On Dec 4, 2011, at 12:58 AM, Matt Luongo wrote: > > > Well, I had already started writing this before I saw your response- so, > if > > you do decide down the road that you care more about immediate > performance > > than keeping DRY... ;) > > > >g.setMaxBufferSize(0) //turn on tx handlings > >g.startTransaction() > > > >found = g.idx('node_auto_index')[[name:'uni...@example.com']].count() > >if (found == 0) { > >//other custom create code could go here, and/or have vars passed > > through json > >results = g.addVertex([:]) > >} else { > >results = g.idx('node_auto_index')[[name:'uni...@example.com > > ']].count().next() > >} > > > >g.stopTransaction(TransactionalGraph.Conclusion.SUCCESS) > >g.setMaxBufferSize(1) > > > >results > > > > would be something like the Groovy you'd use. > > > > I don't blame you for wanting to avoid the many choices available right > now > > - I'm already generating Javascript for traversal pruning and templating > > Gremlin, all in the name of performance... > > > > -- > > Matt Luongo > > Co-Founder, Scholr.ly > > > > > > > > On Sun, Dec 4, 2011 at 2:38 AM, dnagir wrote: > > > >> Thanks Matt. > >> > >> Yeah. I think the transaction API is in making. Would be great addition. > >> > >> The server-side plugin will definitely work, but I personally prefer to > >> use one way of doing things. At least until I will start speaking neo4j > >> natively :) > >> > >> Cheers, > >> Dmytrii > >> http://www.ApproachE.com > >> > >> > >> On 04/12/2011, at 6:35 PM, mhluongo [via Neo4j Community Discussions] > >> wrote: > >> > >>> I've run into this problem, and resorted to using the Gremlin/Groovy > over > >>> REST (via the server-included plugin). > >>> > >>> There really isn't a way to transactionally express a conditional (or > >>> get-or-create) like that over the vanilla REST API, though I'm sure > it's > >> in > >>> the works. > >>> > >>> -- > >>> Matt Luongo > >>> Co-Founder, Scholr.ly > >>> > >>> > >>> > >>> On Thu, Dec 1, 2011 at 5:45 PM, dnagir <[hidden email]> wrote: > >>> > >>>> Hi, > >>>> > >>>> I wonder what's the best way to do something similar to unique > >> constraints > >>>> in RDBMS. > >>>> > >>>> For example, user registration requires that the user's email to be > >> unique. > >>>> > >>>> Working over in Ruby over REST API, how do you achieve this? > >>>> > >>>> I assume I need an auto-index on email property of User nodes. Then > >> query > >>>> it > >>>> to check the property. > >>>> > >>>> But how can I make it transactional? So that I am sure that between > >>>> querying > >>>> and inserting the node, no similar has been inserted. > >>>> > >>>> The transactional part better applies to reservation instead of user > >>>> creation. But you get the point. > >>>> > >>>> Cheers. > >>>> > >>>> -- > >>>> View this message in context: > >>>> > >> > http://neo4j-community-discussions.438527.n3.nabble.com/Unique-constraint-and-transaction-over-REST-tp3553148p3553148.html > >>>> Sent from the Neo4j Community Discussions mailing list archive at > >>>> Nabble.com. > >>>> ___ >
Re: [Neo4j] Unique constraint and transaction over REST
Well, I had already started writing this before I saw your response- so, if you do decide down the road that you care more about immediate performance than keeping DRY... ;) g.setMaxBufferSize(0) //turn on tx handlings g.startTransaction() found = g.idx('node_auto_index')[[name:'uni...@example.com']].count() if (found == 0) { //other custom create code could go here, and/or have vars passed through json results = g.addVertex([:]) } else { results = g.idx('node_auto_index')[[name:'uni...@example.com ']].count().next() } g.stopTransaction(TransactionalGraph.Conclusion.SUCCESS) g.setMaxBufferSize(1) results would be something like the Groovy you'd use. I don't blame you for wanting to avoid the many choices available right now - I'm already generating Javascript for traversal pruning and templating Gremlin, all in the name of performance... -- Matt Luongo Co-Founder, Scholr.ly On Sun, Dec 4, 2011 at 2:38 AM, dnagir wrote: > Thanks Matt. > > Yeah. I think the transaction API is in making. Would be great addition. > > The server-side plugin will definitely work, but I personally prefer to > use one way of doing things. At least until I will start speaking neo4j > natively :) > > Cheers, > Dmytrii > http://www.ApproachE.com > > > On 04/12/2011, at 6:35 PM, mhluongo [via Neo4j Community Discussions] > wrote: > > > I've run into this problem, and resorted to using the Gremlin/Groovy over > > REST (via the server-included plugin). > > > > There really isn't a way to transactionally express a conditional (or > > get-or-create) like that over the vanilla REST API, though I'm sure it's > in > > the works. > > > > -- > > Matt Luongo > > Co-Founder, Scholr.ly > > > > > > > > On Thu, Dec 1, 2011 at 5:45 PM, dnagir <[hidden email]> wrote: > > > > > Hi, > > > > > > I wonder what's the best way to do something similar to unique > constraints > > > in RDBMS. > > > > > > For example, user registration requires that the user's email to be > unique. > > > > > > Working over in Ruby over REST API, how do you achieve this? > > > > > > I assume I need an auto-index on email property of User nodes. Then > query > > > it > > > to check the property. > > > > > > But how can I make it transactional? So that I am sure that between > > > querying > > > and inserting the node, no similar has been inserted. > > > > > > The transactional part better applies to reservation instead of user > > > creation. But you get the point. > > > > > > Cheers. > > > > > > -- > > > View this message in context: > > > > http://neo4j-community-discussions.438527.n3.nabble.com/Unique-constraint-and-transaction-over-REST-tp3553148p3553148.html > > > Sent from the Neo4j Community Discussions mailing list archive at > > > Nabble.com. > > > ___ > > > Neo4j mailing list > > > [hidden email] > > > https://lists.neo4j.org/mailman/listinfo/user > > > > > ___ > > Neo4j mailing list > > [hidden email] > > https://lists.neo4j.org/mailman/listinfo/user > > > > > > If you reply to this email, your message will be added to the discussion > below: > > > http://neo4j-community-discussions.438527.n3.nabble.com/Unique-constraint-and-transaction-over-REST-tp3553148p3558628.html > > To unsubscribe from Unique constraint and transaction over REST, click > here. > > NAML > > > > -- > View this message in context: > http://neo4j-community-discussions.438527.n3.nabble.com/Unique-constraint-and-transaction-over-REST-tp3553148p3558630.html > Sent from the Neo4j Community Discussions mailing list archive at > Nabble.com. > ___ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] Unique constraint and transaction over REST
I've run into this problem, and resorted to using the Gremlin/Groovy over REST (via the server-included plugin). There really isn't a way to transactionally express a conditional (or get-or-create) like that over the vanilla REST API, though I'm sure it's in the works. -- Matt Luongo Co-Founder, Scholr.ly On Thu, Dec 1, 2011 at 5:45 PM, dnagir wrote: > Hi, > > I wonder what's the best way to do something similar to unique constraints > in RDBMS. > > For example, user registration requires that the user's email to be unique. > > Working over in Ruby over REST API, how do you achieve this? > > I assume I need an auto-index on email property of User nodes. Then query > it > to check the property. > > But how can I make it transactional? So that I am sure that between > querying > and inserting the node, no similar has been inserted. > > The transactional part better applies to reservation instead of user > creation. But you get the point. > > Cheers. > > -- > View this message in context: > http://neo4j-community-discussions.438527.n3.nabble.com/Unique-constraint-and-transaction-over-REST-tp3553148p3553148.html > Sent from the Neo4j Community Discussions mailing list archive at > Nabble.com. > ___ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] Will there ever be a native SDK for Node.js?
> > > What are the advantages of using HTTP directly over native SDK like the > Java > > one? > You have to understand that "native" runs as as part of the same process. > And that's why it's supposed to be faster. > Running as part of the app means that you lock the database to one single > app (you can't just go and fix production data). > > With REST, you have a separate server. Thus multiple applications can use. > Or you can access it directly through normal web browser to fix your data. > Or even run background jobs against that server. All that is not possible > with native. Great points here about REST vs in-process use of Neo4j, but... > > > Don't they have a native SDK for Python and Ruby as well (although I > think > > they are just wrappers for tje HTTP API?) > No. Saying "native" it means that it is native to Java only. > So as long as you are on JVM, you can use the native SDK. > > There are versions of Ruby (JRuby) and Python (Jypthon) that are built > specifically to target JVM. And that's why you can use it. > But if you want to use "normal" Ruby or Python, your only option is REST. > This is wrong. There are REST *and* native Python (CPython, not just Jython) bindings, using a Python/JVM interface called JPype. Same applies to your case with Nodejs. So it would seem that if Node.js had an existing interface to the JVM, this would be possible. A quick search didn't find a JPype equivalent for Node, but at least the possibility is hinted at on SO - http://stackoverflow.com/questions/4729013/can-i-call-java-from-node-js-via-jni-and-how -- Matt Luongo Co-Founder, Scholr.ly ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] SO Question for Pythonistas: ORM for Neo4j ?
Put my thoughts in :) -- Matt Luongo Co-Founder, Scholr.ly On Fri, Dec 2, 2011 at 8:56 AM, Michael Hunger < michael.hun...@neotechnology.com> wrote: > Please help answering him, > > thanks a lot. > > > http://stackoverflow.com/questions/8356626/orm-with-graph-databases-like-neo4j-in-python > > i wonder wether there is a solution (or a need for) an ORM with > Graph-Database (f.e. Neo4j). I'm tracking relationships (A is related to B > which is related to A via C etc., thus constructing a large graph) of > entities (including additional attributes for those entities) and need to > store them in a DB, and i think a graph database would fit this task > perfectly. > > Now, with sql-like DBs, i use sqlalchemyś ORM to store my objects, > especially because of the fact that i can retrieve objects from the db and > work with them in a pythonic style (use their methods etc.). > > Is there any object-mapping solution for Neo4j or other Graph-DB, so that > i can store and retrieve python objects into and from the Graph-DB and work > with them easily? > > Or would you write some functions or adapters like in the python sqlite > documentation ( > http://docs.python.org/library/sqlite3.html#letting-your-object-adapt-itself) > to retrieve and store objects? > ___ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] REST, Gremlin and transactions (neo4django's type hierarchy)
Ah, thanks Mattias. -- Matt Luongo Co-Founder, Scholr.ly On Sun, Nov 20, 2011 at 6:12 AM, Mattias Persson wrote: > you must add manually taken locks to LockReleaser to tie them to the > current transaction, otherwise thet will not be released when finishing the > transaction > > Den lördagen den 19:e november 2011 skrev Matt Luongo: > > Peter, > > > > That plus the Gremlin docs both helped. LockManager was actually the > > difficult piece of the puzzle- even once I knew the name of the class and > > had the java docs, some things online seemed to suggest that closing a > > transaction would release read locks (not true, in my experience thus > far). > > > > For posterity -> http://wiki.neo4j.org/content/Locks and > > http://wiki.neo4j.org/content/Transactions#Isolation were both very > helpful. > > > > -- > > Matt Luongo > > Co-Founder, Scholr.ly > > > > > > > > On Sat, Nov 19, 2011 at 4:17 PM, Peter Neubauer < > > peter.neuba...@neotechnology.com> wrote: > > > >> Great Matt, > >> Did you find this via > >> > >> > > http://docs.neo4j.org/chunked/snapshot/gremlin-plugin.html#rest-api-send-an-arbitrary-groovy-script---lucene-sortingor > >> should it be better documented? > >> On Nov 19, 2011 9:56 PM, "Matt Luongo" wrote: > >> > >> > Aha! Scratched my own itch. For anyone interested... > >> > > >> > I found Gremlin's getRawGraph(), which let's me play with the > >> LockManager. > >> > > >> >g.setMaxBufferSize(0) > >> >g.startTransaction() > >> >lockManager = g.getRawGraph().getConfig().getLockManager() > >> > > >> >locked = [] > >> >curVertex = g.v(0) > >> >for (def typeProps : types) { > >> >rawVertex = curVertex.getRawVertex() > >> >lockManager.getReadLock(rawVertex) > >> >locked << rawVertex > >> > > >> >candidate = curVertex.outE('<>').inV.find{ > >> >it.map.subMap(typeProps.keySet()) == typeProps > >> >} > >> >if (candidate == null) { > >> >newTypeNode = g.addVertex(typeProps) > >> >name = typeProps['app_label'] + ":" + > typeProps['model_name'] > >> >newTypeNode.name = name > >> >g.addEdge(curVertex, newTypeNode, "<>") > >> >curVertex = newTypeNode > >> >} > >> >else { > >> > curVertex = candidate > >> >} > >> >} > >> >for (def lockedRes : locked) { > >> >lockManager.releaseReadLock(lockedRes, null) > >> >} > >> >g.stopTransaction(TransactionalGraph.Conclusion.SUCCESS) > >> > > >> >result = curVertex > >> > > >> > Of course this puts a read lock on the reference node, which stinks, > but > >> > it's what the problem required. > >> > I'm going to memoize the result of this client-side so it only gets > >> called > >> > a couple times. > >> > > >> > -- > >> > Matt Luongo > >> > Co-Founder, Scholr.ly > >> > > >> > > >> > > >> > On Sat, Nov 19, 2011 at 2:46 AM, Matt Luongo wrote: > >> > > >> > > Guys, > >> > > > >> > > I'm trying to get neo4django's type hierarchy behaving in a safe way > >> for > >> > > multiprocessing. I ducked the > >> > > REST API proper and am using the Gremlin extension, since I need the > >> type > >> > > creation operation to be atomic. > >> > > > >> > > The hierarchy is a simple single-inheritance system represented > >> in-graph > >> > > as a tree rooted at the reference > >> > > node. Each node in the tree represents a type, including it's name > >> > > (`model_name`) and the module the type > >> > > was defined in (`app_label`). > >> > > > >> > > I came up with the following script > >> > > > >> > > g.setMaxBufferSize(0) > >> > > g.startTransaction() > >> > > > >> > > cur_vertex = g.v(0) > >> > > for (def type_props : types) { > >> > > candidate = cur_vertex.outE('<>').inV.find{ > >> > > it.map.subMap(type_props.keySet()) == type_props > >> > > } > >> > > if (candidate == nu > > -- > Mattias Persson, [matt...@neotechnology.com] > Hacker, Neo Technology > www.neotechnology.com > ___ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] REST, Gremlin and transactions (neo4django's type hierarchy)
Peter, That plus the Gremlin docs both helped. LockManager was actually the difficult piece of the puzzle- even once I knew the name of the class and had the java docs, some things online seemed to suggest that closing a transaction would release read locks (not true, in my experience thus far). For posterity -> http://wiki.neo4j.org/content/Locks and http://wiki.neo4j.org/content/Transactions#Isolation were both very helpful. -- Matt Luongo Co-Founder, Scholr.ly On Sat, Nov 19, 2011 at 4:17 PM, Peter Neubauer < peter.neuba...@neotechnology.com> wrote: > Great Matt, > Did you find this via > > http://docs.neo4j.org/chunked/snapshot/gremlin-plugin.html#rest-api-send-an-arbitrary-groovy-script---lucene-sortingor > should it be better documented? > On Nov 19, 2011 9:56 PM, "Matt Luongo" wrote: > > > Aha! Scratched my own itch. For anyone interested... > > > > I found Gremlin's getRawGraph(), which let's me play with the > LockManager. > > > >g.setMaxBufferSize(0) > >g.startTransaction() > >lockManager = g.getRawGraph().getConfig().getLockManager() > > > >locked = [] > >curVertex = g.v(0) > >for (def typeProps : types) { > >rawVertex = curVertex.getRawVertex() > >lockManager.getReadLock(rawVertex) > >locked << rawVertex > > > >candidate = curVertex.outE('<>').inV.find{ > >it.map.subMap(typeProps.keySet()) == typeProps > >} > >if (candidate == null) { > >newTypeNode = g.addVertex(typeProps) > >name = typeProps['app_label'] + ":" + typeProps['model_name'] > >newTypeNode.name = name > >g.addEdge(curVertex, newTypeNode, "<>") > >curVertex = newTypeNode > >} > >else { > >curVertex = candidate > >} > >} > >for (def lockedRes : locked) { > >lockManager.releaseReadLock(lockedRes, null) > >} > >g.stopTransaction(TransactionalGraph.Conclusion.SUCCESS) > > > >result = curVertex > > > > Of course this puts a read lock on the reference node, which stinks, but > > it's what the problem required. > > I'm going to memoize the result of this client-side so it only gets > called > > a couple times. > > > > -- > > Matt Luongo > > Co-Founder, Scholr.ly > > > > > > > > On Sat, Nov 19, 2011 at 2:46 AM, Matt Luongo wrote: > > > > > Guys, > > > > > > I'm trying to get neo4django's type hierarchy behaving in a safe way > for > > > multiprocessing. I ducked the > > > REST API proper and am using the Gremlin extension, since I need the > type > > > creation operation to be atomic. > > > > > > The hierarchy is a simple single-inheritance system represented > in-graph > > > as a tree rooted at the reference > > > node. Each node in the tree represents a type, including it's name > > > (`model_name`) and the module the type > > > was defined in (`app_label`). > > > > > > I came up with the following script > > > > > > g.setMaxBufferSize(0) > > > g.startTransaction() > > > > > > cur_vertex = g.v(0) > > > for (def type_props : types) { > > > candidate = cur_vertex.outE('<>').inV.find{ > > > it.map.subMap(type_props.keySet()) == type_props > > > } > > > if (candidate == null) { > > > new_type_node = g.addVertex(type_props) > > > name = type_props['app_label'] + ":" + > > type_props['model_name'] > > > new_type_node.name = name > > > g.addEdge(cur_vertex, new_type_node, "<>") > > > cur_vertex = new_type_node > > > } > > > else { > > > cur_vertex = candidate > > > } > > > } > > > > > > g.stopTransaction(TransactionalGraph.Conclusion.SUCCESS) > > > > > > result = cur_vertex > > > > > > which searches for a type node that fits the type lineage sent in > through > > > the JSON-encoded `types` > > > list. The code works fine as a replacement for how I was managing types > > > in-graph. > > > > > > However, if I send this script (again, through REST) using three >
Re: [Neo4j] REST, Gremlin and transactions (neo4django's type hierarchy)
Aha! Scratched my own itch. For anyone interested... I found Gremlin's getRawGraph(), which let's me play with the LockManager. g.setMaxBufferSize(0) g.startTransaction() lockManager = g.getRawGraph().getConfig().getLockManager() locked = [] curVertex = g.v(0) for (def typeProps : types) { rawVertex = curVertex.getRawVertex() lockManager.getReadLock(rawVertex) locked << rawVertex candidate = curVertex.outE('<>').inV.find{ it.map.subMap(typeProps.keySet()) == typeProps } if (candidate == null) { newTypeNode = g.addVertex(typeProps) name = typeProps['app_label'] + ":" + typeProps['model_name'] newTypeNode.name = name g.addEdge(curVertex, newTypeNode, "<>") curVertex = newTypeNode } else { curVertex = candidate } } for (def lockedRes : locked) { lockManager.releaseReadLock(lockedRes, null) } g.stopTransaction(TransactionalGraph.Conclusion.SUCCESS) result = curVertex Of course this puts a read lock on the reference node, which stinks, but it's what the problem required. I'm going to memoize the result of this client-side so it only gets called a couple times. -- Matt Luongo Co-Founder, Scholr.ly On Sat, Nov 19, 2011 at 2:46 AM, Matt Luongo wrote: > Guys, > > I'm trying to get neo4django's type hierarchy behaving in a safe way for > multiprocessing. I ducked the > REST API proper and am using the Gremlin extension, since I need the type > creation operation to be atomic. > > The hierarchy is a simple single-inheritance system represented in-graph > as a tree rooted at the reference > node. Each node in the tree represents a type, including it's name > (`model_name`) and the module the type > was defined in (`app_label`). > > I came up with the following script > > g.setMaxBufferSize(0) > g.startTransaction() > > cur_vertex = g.v(0) > for (def type_props : types) { > candidate = cur_vertex.outE('<>').inV.find{ > it.map.subMap(type_props.keySet()) == type_props > } > if (candidate == null) { > new_type_node = g.addVertex(type_props) > name = type_props['app_label'] + ":" + type_props['model_name'] > new_type_node.name = name > g.addEdge(cur_vertex, new_type_node, "<>") > cur_vertex = new_type_node > } > else { > cur_vertex = candidate > } > } > > g.stopTransaction(TransactionalGraph.Conclusion.SUCCESS) > > result = cur_vertex > > which searches for a type node that fits the type lineage sent in through > the JSON-encoded `types` > list. The code works fine as a replacement for how I was managing types > in-graph. > > However, if I send this script (again, through REST) using three threads > simultaneously, I don't get > the expected behavior. Instead of the first request resulting in one new > type node, and the other two > returning the node created by the first, three nodes are created and > returned. Which is irksome. > > I'm pretty sure this is due to my own ignorance, but I've tried to do my > homework. > http://wiki.neo4j.org/content/Transactions#Isolation leads me to believe > that maybe code like above > won't work, because it only writes on condition after a read, but doesn't > have a read lock. Could this > be the case? and if so, is there a suggested fix in Gremlin? > > Any help/intuition would be greatly appreciated! > > -- > Matt Luongo > Co-Founder, Scholr.ly > ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
[Neo4j] REST, Gremlin and transactions (neo4django's type hierarchy)
Guys, I'm trying to get neo4django's type hierarchy behaving in a safe way for multiprocessing. I ducked the REST API proper and am using the Gremlin extension, since I need the type creation operation to be atomic. The hierarchy is a simple single-inheritance system represented in-graph as a tree rooted at the reference node. Each node in the tree represents a type, including it's name (`model_name`) and the module the type was defined in (`app_label`). I came up with the following script g.setMaxBufferSize(0) g.startTransaction() cur_vertex = g.v(0) for (def type_props : types) { candidate = cur_vertex.outE('<>').inV.find{ it.map.subMap(type_props.keySet()) == type_props } if (candidate == null) { new_type_node = g.addVertex(type_props) name = type_props['app_label'] + ":" + type_props['model_name'] new_type_node.name = name g.addEdge(cur_vertex, new_type_node, "<>") cur_vertex = new_type_node } else { cur_vertex = candidate } } g.stopTransaction(TransactionalGraph.Conclusion.SUCCESS) result = cur_vertex which searches for a type node that fits the type lineage sent in through the JSON-encoded `types` list. The code works fine as a replacement for how I was managing types in-graph. However, if I send this script (again, through REST) using three threads simultaneously, I don't get the expected behavior. Instead of the first request resulting in one new type node, and the other two returning the node created by the first, three nodes are created and returned. Which is irksome. I'm pretty sure this is due to my own ignorance, but I've tried to do my homework. http://wiki.neo4j.org/content/Transactions#Isolation leads me to believe that maybe code like above won't work, because it only writes on condition after a read, but doesn't have a read lock. Could this be the case? and if so, is there a suggested fix in Gremlin? Any help/intuition would be greatly appreciated! -- Matt Luongo Co-Founder, Scholr.ly ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] Scalability Roadmap
Jim, Not to nitpick, but that's for an ideal graph partitioning, not graph sharding overall, right? Eg the problem is solvable in many specific domains? - Matt On Nov 18, 2011 1:27 PM, "Jim Webber" wrote: > > 1/ Supernode > > 2012, around Q2. > > > 2/ Sharding and horizontal scalability > > 2013, around Q1. > > These are guesses not promises :-) > > Jim > > PS - sharding graphs is NP complete. In theory no general solution exists. > ___ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] Executing arbitrary code through REST (was: Specifying "best first" order of traverse over REST API)
Looks like the best-order stuff is being covered just fine in the other thread, nevermind :) -- Matt Luongo Co-Founder, Scholr.ly On Fri, Aug 26, 2011 at 1:20 PM, Matt Luongo wrote: > Peter, > > The arbitrary Groovy is great, but if I understand correctly, there still > isn't a straightforward way to do a best-first traversal *with* paging- is > there? It seems like that would require being able to introduce some sort of > server-side state through the GremlinPlugin (for pages). Maybe the solution > would be to re-run the traversal each time, and then return different > slices, but that's a pretty painful tradeoff. > > -- > Matt Luongo > Co-Founder, Scholr.ly > > > > On Fri, Aug 26, 2011 at 1:12 PM, Matt Luongo wrote: > >> You can run the script through the Python neo4jrestclient by using the >> extension support. >> >> Try >> import neo4jrestclient.client as client >> gdb = client.GraphDatabase('http://localhost:7474/db/data') >> gdb.extensions.GremlinPlugin.execute_script(script="...") >> >> I think Javier is working on adding a "returns=" style parameter in >> the most recent source so that >> the client can figure out what type to cast the data into- >> >> import neo4jrestclient.constants as constants >> gdb.extensions.GremlinPlugin.execute_script(script="...", >> returns=constants.NODE) >> >> But I haven't gotten this working quite yet. >> >> -- >> Matt Luongo >> Co-Founder, Scholr.ly >> >> >> >> On Fri, Aug 26, 2011 at 12:11 PM, Boris Kizelshteyn wrote: >> >>> I didn't have luck running it through neo4jrest, but the following >>> function >>> does the trick for me: >>> >>> script = "g.v(0)" >>> >>> def RunGremlinScript(script): >>> >>>content=[] >>> >>>jout=[] >>> >>>out={} >>> >>>try: >>> >>>h = Http() >>> >>>response, content = h.request(GRAPHSERVER + >>> "ext/GremlinPlugin/graphdb/execute_script",\ >>>"POST",\ >>>json.dumps(dict(script=script)), \ >>>headers={'Accept':'application/json', >>> 'Content-type': 'application/json'}) >>> >>> >>>jcontent = json.loads(content) >>> >>>for x in jcontent: >>> >>>if isinstance(x, dict): >>> >>>for arr in x['data']: >>> >>>for e in range(len(arr)): >>> >>>out[str(x['columns'][e])] = arr[e] >>> >>>jout.append(dict(out)) >>> >>>else: >>> >>>return jcontent >>> >>>except: >>> >>>print "Unexpected error running gremlin: ", sys.exc_info()[0] >>> >>>print str(traceback.print_exc()) >>> >>>print jcontent >>> >>>return [{}] >>> >>>return jout >>> >>> On Fri, Aug 26, 2011 at 12:01 PM, Jacopo Farina < >>> jacopo1.far...@gmail.com>wrote: >>> >>> > Nice! >>> > is there a way to run it easily from python with neo4jrestclient, >>> avoiding >>> > creating an http request manually ? In general, I wasn't able to >>> understand >>> > how to run a Gremlin script, or just a query, in python through the >>> > restclient library. >>> > Probably is a very simple business, but I started using it in Python >>> just >>> > yesterday. >>> > >>> > Cheers, >>> > Jacopo >>> > >>> > 2011/8/25 Peter Neubauer >>> > >>> > > Guys, >>> > > with the custom sorting in Lucene and this thread coming up all the >>> time, >>> > I >>> > > took the time to document the execution of arbitrary Groovy and thus, >>> > Java >>> > > calls through REST. In the example below, there are calls to Neo4j >>> APIs, >>> > > Gremlin stuff and custom sorting using Lucene classes, and return of >>> a >>> > > Neo4j >>> > > search hit object. >>> > > >>> > &
Re: [Neo4j] Executing arbitrary code through REST (was: Specifying "best first" order of traverse over REST API)
Peter, The arbitrary Groovy is great, but if I understand correctly, there still isn't a straightforward way to do a best-first traversal *with* paging- is there? It seems like that would require being able to introduce some sort of server-side state through the GremlinPlugin (for pages). Maybe the solution would be to re-run the traversal each time, and then return different slices, but that's a pretty painful tradeoff. -- Matt Luongo Co-Founder, Scholr.ly On Fri, Aug 26, 2011 at 1:12 PM, Matt Luongo wrote: > You can run the script through the Python neo4jrestclient by using the > extension support. > > Try > import neo4jrestclient.client as client > gdb = client.GraphDatabase('http://localhost:7474/db/data') > gdb.extensions.GremlinPlugin.execute_script(script="...") > > I think Javier is working on adding a "returns=" style parameter in > the most recent source so that > the client can figure out what type to cast the data into- > > import neo4jrestclient.constants as constants > gdb.extensions.GremlinPlugin.execute_script(script="...", > returns=constants.NODE) > > But I haven't gotten this working quite yet. > > -- > Matt Luongo > Co-Founder, Scholr.ly > > > > On Fri, Aug 26, 2011 at 12:11 PM, Boris Kizelshteyn wrote: > >> I didn't have luck running it through neo4jrest, but the following >> function >> does the trick for me: >> >> script = "g.v(0)" >> >> def RunGremlinScript(script): >> >>content=[] >> >>jout=[] >> >>out={} >> >>try: >> >>h = Http() >> >>response, content = h.request(GRAPHSERVER + >> "ext/GremlinPlugin/graphdb/execute_script",\ >>"POST",\ >>json.dumps(dict(script=script)), \ >>headers={'Accept':'application/json', >> 'Content-type': 'application/json'}) >> >> >>jcontent = json.loads(content) >> >>for x in jcontent: >> >>if isinstance(x, dict): >> >>for arr in x['data']: >> >>for e in range(len(arr)): >> >>out[str(x['columns'][e])] = arr[e] >> >>jout.append(dict(out)) >> >>else: >> >>return jcontent >> >>except: >> >>print "Unexpected error running gremlin: ", sys.exc_info()[0] >> >>print str(traceback.print_exc()) >> >>print jcontent >> >>return [{}] >> >>return jout >> >> On Fri, Aug 26, 2011 at 12:01 PM, Jacopo Farina > >wrote: >> >> > Nice! >> > is there a way to run it easily from python with neo4jrestclient, >> avoiding >> > creating an http request manually ? In general, I wasn't able to >> understand >> > how to run a Gremlin script, or just a query, in python through the >> > restclient library. >> > Probably is a very simple business, but I started using it in Python >> just >> > yesterday. >> > >> > Cheers, >> > Jacopo >> > >> > 2011/8/25 Peter Neubauer >> > >> > > Guys, >> > > with the custom sorting in Lucene and this thread coming up all the >> time, >> > I >> > > took the time to document the execution of arbitrary Groovy and thus, >> > Java >> > > calls through REST. In the example below, there are calls to Neo4j >> APIs, >> > > Gremlin stuff and custom sorting using Lucene classes, and return of a >> > > Neo4j >> > > search hit object. >> > > >> > > You can do all this in a Neo4j Server plugin, but if you need to, this >> is >> > > an >> > > example on how to do it with only REST. >> > > >> > > >> > > >> > >> http://docs.neo4j.org/chunked/snapshot/gremlin-plugin.html#rest-api-send-an-arbitrary-groovy-script---lucene-sorting >> > > >> > > Hope that helps for future reference! >> > > >> > > Cheers, >> > > >> > > /peter neubauer >> > > >> > > GTalk: neubauer.peter >> > > Skype peter.neubauer >> > > Phone +46 704 106975 >> > > LinkedIn http://www.linkedin.com/in/
Re: [Neo4j] Executing arbitrary code through REST (was: Specifying "best first" order of traverse over REST API)
You can run the script through the Python neo4jrestclient by using the extension support. Try import neo4jrestclient.client as client gdb = client.GraphDatabase('http://localhost:7474/db/data') gdb.extensions.GremlinPlugin.execute_script(script="...") I think Javier is working on adding a "returns=" style parameter in the most recent source so that the client can figure out what type to cast the data into- import neo4jrestclient.constants as constants gdb.extensions.GremlinPlugin.execute_script(script="...", returns=constants.NODE) But I haven't gotten this working quite yet. -- Matt Luongo Co-Founder, Scholr.ly On Fri, Aug 26, 2011 at 12:11 PM, Boris Kizelshteyn wrote: > I didn't have luck running it through neo4jrest, but the following function > does the trick for me: > > script = "g.v(0)" > > def RunGremlinScript(script): > >content=[] > >jout=[] > >out={} > >try: > >h = Http() > >response, content = h.request(GRAPHSERVER + > "ext/GremlinPlugin/graphdb/execute_script",\ >"POST",\ >json.dumps(dict(script=script)), \ >headers={'Accept':'application/json', > 'Content-type': 'application/json'}) > > >jcontent = json.loads(content) > >for x in jcontent: > >if isinstance(x, dict): > >for arr in x['data']: > >for e in range(len(arr)): > >out[str(x['columns'][e])] = arr[e] > >jout.append(dict(out)) > >else: > >return jcontent > >except: > >print "Unexpected error running gremlin: ", sys.exc_info()[0] > >print str(traceback.print_exc()) > >print jcontent > >return [{}] > >return jout > > On Fri, Aug 26, 2011 at 12:01 PM, Jacopo Farina >wrote: > > > Nice! > > is there a way to run it easily from python with neo4jrestclient, > avoiding > > creating an http request manually ? In general, I wasn't able to > understand > > how to run a Gremlin script, or just a query, in python through the > > restclient library. > > Probably is a very simple business, but I started using it in Python just > > yesterday. > > > > Cheers, > > Jacopo > > > > 2011/8/25 Peter Neubauer > > > > > Guys, > > > with the custom sorting in Lucene and this thread coming up all the > time, > > I > > > took the time to document the execution of arbitrary Groovy and thus, > > Java > > > calls through REST. In the example below, there are calls to Neo4j > APIs, > > > Gremlin stuff and custom sorting using Lucene classes, and return of a > > > Neo4j > > > search hit object. > > > > > > You can do all this in a Neo4j Server plugin, but if you need to, this > is > > > an > > > example on how to do it with only REST. > > > > > > > > > > > > http://docs.neo4j.org/chunked/snapshot/gremlin-plugin.html#rest-api-send-an-arbitrary-groovy-script---lucene-sorting > > > > > > Hope that helps for future reference! > > > > > > Cheers, > > > > > > /peter neubauer > > > > > > GTalk: neubauer.peter > > > Skype peter.neubauer > > > Phone +46 704 106975 > > > LinkedIn http://www.linkedin.com/in/neubauer > > > Twitter http://twitter.com/peterneubauer > > > > > > http://www.neo4j.org - Your high performance graph > > database. > > > http://startupbootcamp.org/- Öresund - Innovation happens HERE. > > > http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing > party. > > > > > > > > > On Thu, Aug 25, 2011 at 1:00 AM, Matt Luongo wrote: > > > > > > > +1, we could really use that. Client-side sorting sucks. > > > > > > > > -- > > > > Matt Luongo > > > > Co-Founder, Scholr.ly > > > > > > > > > > > > > > > > On Wed, Aug 24, 2011 at 4:43 PM, Aseem Kishore < > > aseem.kish...@gmail.com > > > > >wrote: > > > > > > > > > I've just spent a bunch of time reading into how one can control > the > > > > > ordering of a traverse beyond simple "breadth first"
Re: [Neo4j] Specifying "best first" order of traverse over REST API
+1, we could really use that. Client-side sorting sucks. -- Matt Luongo Co-Founder, Scholr.ly On Wed, Aug 24, 2011 at 4:43 PM, Aseem Kishore wrote: > I've just spent a bunch of time reading into how one can control the > ordering of a traverse beyond simple "breadth first" or "depth first". More > precisely, even when breadth first, how one can control *which* neighbors > are traversed first. > > (It matters less in which order they're traversed vs. which order they're > returned if you're returning all results, since you can just sort on the > client. But it matters a lot if you want to use the paged traverser, since > you're then only returning the first results.) > > I've learned that this is doable from Java by writing your own > BranchSelector implementation: > > http://components.neo4j.org/neo4j/1.4.1/apidocs/ > > I've found the built-in implementations, e.g. the pre-order breadth-first > and depth-first: > > > https://github.com/neo4j/community/blob/master/kernel/src/main/java/org/neo4j/kernel/PreorderBreadthFirstSelector.java > > > https://github.com/neo4j/community/blob/master/kernel/src/main/java/org/neo4j/kernel/PreorderDepthFirstSelector.java > > To achieve a custom "best first", Igor Dovgiy for example shared that he > modeled his implementation of the breadth-first selector, except just using > a PriorityQueue instead of a regular Queue. > > My question is: is there any way to specify this sort of thing over the > REST > API instead of having to write a plugin? If not, does that sound like a > reasonable feature request? > > I really just want something simple: nodes ordered by some "timestamp" > property. It's killing us that we can't do this today. We might just have > to > look into writing this as a plugin... > > Thanks! > > Aseem > ___ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
[Neo4j] Announcing neo4django
Graphistas, We just released an earlyish version of our Django / Neo4j REST integration on GitHub <https://github.com/scholrly/neo4django>. I wrote a couple paragraphs about it on my blog<http://mattluongo.com/post/when-to-open-source>. If you like it, make sure you thank Tobias for the original integration on which this was based, and Javier for the REST client it's using now. Please let me know what you think! If you have any questions, or are at all interested in contributing, feel free to talk to me or jump right in on GitHub - I can't wait to get this out into the wild. -- Matt Luongo Co-Founder, Scholr.ly ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] auto indexes in REST in 1.4?
+1, we could use configuration through REST as well. -- Matt Luongo Co-Founder, Scholr.ly On Tue, Jul 12, 2011 at 6:45 AM, mike_t wrote: > Please tell me, how can I do that? I couldn´t find anything about it in the > api doc (http://components.neo4j.org/neo4j-server/snapshot/rest.html) > > -- > View this message in context: > http://neo4j-user-list.438527.n3.nabble.com/Neo4j-auto-indexes-in-REST-in-1-4-tp3159205p3162053.html > Sent from the Neo4J User List mailing list archive at Nabble.com. > ___ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] REST API & LuceneTimeline
If anyone else needs this functionality- we've thrown together a quick plugin for indexing longs at https://github.com/scholrly/neo4j-valuecontext-plugin. -- Matt Luongo Co-Founder, Scholr.ly On Thu, Jun 16, 2011 at 10:12 AM, Mattias Persson wrote: > Yes, you're probably right in that instead POSTing with a payload of key, > value and entity would provide the functionality needed here. It's a ticket > at least and hopefully it will be fixed soon. > > 2011/6/15 Rick Bullotta > > > Depends I would think on how you are putting/posting the data. If via > XML > > or URL parameters, I can't see how Neo would know whether it was a string > or > > a number, but if via JSON you should be able to get it in there properly. > > > > Perhaps the REST API should support passing content via either the URL or > > via a POST'ed payload. That's what we do with our internally created > REST > > API today (support URL parameters, XML, or JSON for all calls, with the > URI > > defining the "intent" or the "method" and query parameters XML/JSON > defining > > the "parameters"). > > > > I know the REST API has some "soak time" already, but I would seriously > > consider redesigning parts of it to treat some of the parameters > differently > > when the Content-Type is JSON (e.g. pass them in the payload, not the > URI, > > as with the REST API that lets you create a node w/properties). Let's > take > > indexing for example. The approach I'm proposing would allow an atomic > call > > to index multiple fields, rather than one at a time, as with the current > > approach, and it would allow more flexible data types. Indexing all the > > fields at once is, to me, an essential capability to ensure the semantic > > integrity of the graph. > > > > An example is: > > > > POST http://localhost:7474/db/data/index/node/favorites > > > > POST Content : > > > > { > > "fields" : [ > >{ > > "key" : "key1" > > "value" : 12345 > >}, > >{ > > "key" : "key2" > > "value" : "ABC" > >}, > >{ > > "key" : "key3" > > "value" : [ "Dogs", "Cats", "Sheep" ] > >} > > ] > > } > > > > *Accept: application/json > > *Content-Type: application/json > > > > > > -Original Message- > > From: Peter Neubauer [mailto:neubauer.pe...@gmail.com] > > Sent: Wednesday, June 15, 2011 10:30 AM > > To: Matt Luongo > > Cc: Neo4j user discussions; Rick Bullotta > > Subject: Re: [Neo4j] REST API & LuceneTimeline > > > > Matt, > > inserting by other than String in > > > > > http://docs.neo4j.org/chunked/snapshot/rest-api-indexes.html#rest-api-add-node-to-index > > is not supported. A shortcoming. This is probably what your plugin > > should be doing in that case. Will add that as a ticket to be tracked. > > > > > > > http://neo4jdb.lighthouseapp.com/projects/77609-neo4j-community/tickets/9-support-inserting-index-values-other-than-string-via-rest > > > > -peter > > > > On Wed, Jun 15, 2011 at 4:27 PM, Matt Luongo wrote: > > > It does- awesome, I didn't realize the query syntax would work for > > > numeric fields, as well. Now I just need to figure out how to insert > > > into a numeric field via rest. > > > > > > -- > > > Matt Luongo > > > Co-Founder, Scholr.ly > > > > > > > > > > > > On Wed, Jun 15, 2011 at 10:24 AM, Rick Bullotta > > > wrote: > > >> Hi, Matt. > > >> > > >> We don't use the REST API (we use Neo4J in an embedded mode), so I > can't > > be of much help there. If the REST API supports Lucene query syntax, you > > can use something like: > > >> > > >> timestamp : [1 to 2] > > >> > > >> You'd need to do the Date <-> UTC milliseconds conversion on the front > > end, I'd think. > > >> > > >> Rick > > >> > > >> -Original Message- > > >> From: user-boun...@lists.neo4j.org [mailto: > user-boun...@lists.neo4j.org] > > On Behalf Of Matt Luongo > > >> Sent: Wednesday, June 15, 2011 10:03 AM > > >> To: Peter Neubauer > &g
Re: [Neo4j] Auto Indexing for Neo4j
Peter, Did this get done before the feature freeze? I'm still trying to find a way to query/configure an autoindex via REST. -- Matt Luongo Co-Founder, Scholr.ly On Tue, Jun 14, 2011 at 5:32 PM, Peter Neubauer < peter.neuba...@neotechnology.com> wrote: > Yes, > configuration and indexing via REST is the next step for this. > > Cheers, > > /peter neubauer > > GTalk: neubauer.peter > Skype peter.neubauer > Phone +46 704 106975 > LinkedIn http://www.linkedin.com/in/neubauer > Twitter http://twitter.com/peterneubauer > > http://www.neo4j.org - Your high performance graph database. > http://startupbootcamp.org/- Öresund - Innovation happens HERE. > http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party. > > > > On Tue, Jun 14, 2011 at 7:25 PM, Aseem Kishore > wrote: > > Awesome to hear, and great work! Will we be able to configure+use this > from > > the REST API? > > > > Cheers, > > Aseem > > > > On Tue, Jun 14, 2011 at 8:30 AM, Chris Gioran < > > chris.gio...@neotechnology.com> wrote: > > > >> Good news everyone, > >> > >> A request that's often come up on the mailing list is a mechanism for > >> automatically indexing properties of nodes and relationships. > >> > >> As of today's SNAPSHOT, auto-indexing is part of Neo4j which means nodes > >> and relationships can now be indexed based on convention, requiring > >> far less effort and code from the developer's point of view. > >> > >> Getting hold of an automatic index is straightforward: > >> > >> AutoIndexer nodeAutoIndexer = > graphDb.index().getNodeAutoIndexer(); > >> AutoIndex nodeAutoIndex = nodeAutoIndexer.getAutoIndex(); > >> > >> Once you've got an instance of AutoIndex, you can use it as a read-only > >> Index. > >> > >> The AutoIndexer interface also supports runtime changes and > >> enabling/disabling the auto indexing functionality. > >> > >> To support the new features, there are new Config > >> options you can pass to the startup configuration map in > >> EmbeddedGraphDatabase, the most important of which are: > >> > >> Config.NODE_AUTO_INDEXING (defaults to "false") > >> Config.RELATIONSHIP_AUTO_INDEXING (defaults to "false") > >> > >> If set to "true" (independently of each other) these properties will > >> enable auto indexing functionality and at the successful finish() of > >> each transaction, all newly added properties on the primitives for which > >> auto indexing is enabled will be added to a special AutoIndex (and > >> deleted or changed properties will be updated accordingly too). > >> > >> There are options for fine grained control to determine > >> properties are indexed, default behaviors and so forth. For example, by > >> default all properties are indexed. If you want only properties "name" > and > >> "age" for Nodes and "since" and "until" for Relationships > >> to be auto indexed, simply set the initial configuration as follows: > >> > >> Config.NODE_KEYS_INDEXABLE = "name, age"; > >> Config.RELATIONSHIP_KEYS_INDEXABLE="since, until"; > >> > >> For the semantics of the auto-indexing operations, constraints and more > >> detailed examples, see the documentation available at > >> > >> http://docs.neo4j.org/chunked/1.4-SNAPSHOT/auto-indexing.html > >> > >> We're pretty excited about this feature since we think it'll make your > >> lives > >> as developers much more productive in a range of use-cases. If you're > >> comfortable with using SNAPSHOT versions of Neo4j, please try it out > >> and let us know what you think - we'd really value your feedback. > >> > >> If you're happier with using packaged milestones then this feature > >> will be available from 1.4 M05 in a couple of weeks from now. > >> ___ > >> Neo4j mailing list > >> User@lists.neo4j.org > >> https://lists.neo4j.org/mailman/listinfo/user > >> > > ___ > > Neo4j mailing list > > User@lists.neo4j.org > > https://lists.neo4j.org/mailman/listinfo/user > > > ___ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] REST API & LuceneTimeline
It does- awesome, I didn't realize the query syntax would work for numeric fields, as well. Now I just need to figure out how to insert into a numeric field via rest. -- Matt Luongo Co-Founder, Scholr.ly On Wed, Jun 15, 2011 at 10:24 AM, Rick Bullotta wrote: > Hi, Matt. > > We don't use the REST API (we use Neo4J in an embedded mode), so I can't be > of much help there. If the REST API supports Lucene query syntax, you can > use something like: > > timestamp : [1 to 2] > > You'd need to do the Date <-> UTC milliseconds conversion on the front end, > I'd think. > > Rick > > -Original Message- > From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org] On > Behalf Of Matt Luongo > Sent: Wednesday, June 15, 2011 10:03 AM > To: Peter Neubauer > Cc: user@lists.neo4j.org > Subject: Re: [Neo4j] REST API & LuceneTimeline > > Peter, > > Kind of. I see how I could do that server-side, but not how to insert > elements into the index numerically (with > ValueContext(val).indexNumeric()) or query by range ( > .query(QueryContext.numericRange() ) via REST. Is this something > that will require our writing a plugin to support, or is there > currently some way to index and query numerically via the REST API? > > -- > Matt Luongo > Co-Founder, Scholr.ly > > > > On Wed, Jun 15, 2011 at 9:25 AM, Peter Neubauer > wrote: >> Yeah, >> just checked with Mattias. There is no such index configuration, so >> this does not work. I think you should use the numeric field in a >> normal index for this, just like Rick points out. >> >> Does that make sense? >> >> /peter >> >> On Wed, Jun 15, 2011 at 3:03 PM, Matt Luongo wrote: >>> Peter, >>> >>> I believe it was something like >>> >>> curl -X POST -H Accept:application/json -HContent-Type:application/json -d \ >>> '{"name":"time", "config":{"type":"timeline","provider":"lucene"}}' \ >>> http://localhost:7474/db/data/index/node >>> >>> curl -HContent-Type:application/json -X POST -d \ >>> '"http://localhost:7474/db/data/node/0";' \ >>> http://localhost:7474/db/data/index/node/time/timestamp/25 >>> >>> which gives a 500. >>> -- >>> Matt Luongo >>> Co-Founder, Scholr.ly >>> >>> >>> On Wed, Jun 15, 2011 at 8:55 AM, Rick Bullotta >>> wrote: >>>> >>>> You really don't need a timeline index to do a timeline index, if that >>>> makes sense. As mattias points out, it is just a convenient wrapper >>>> around a plain lucene (neo) index. Just index the timestamp as a numeric >>>> field. >>>> >>>> >>>> >>>> - Reply message - >>>> From: "Matt Luongo" >>>> Date: Wed, Jun 15, 2011 8:48 am >>>> Subject: [Neo4j] REST API & LuceneTimeline >>>> To: "Neo4j user discussions" >>>> >>>> Peter, >>>> >>>> I've done a bit more research, and you're right- it isn't. However, the >>>> REST >>>> api let's me create an index of type 'timeline'. The first time I try to >>>> index a node, there's a 500 error (nullpointer) that stems from the index >>>> not being created. I'd be happy to file a bug report. >>>> >>>> Anyway, we're trying to put together a plugin to expose timeline indexing >>>> via REST. >>>> >>>> - Matt >>>> On Jun 15, 2011 5:49 AM, "Peter Neubauer" >>>> >>>> wrote: >>>> > Matt, >>>> > what URL are you using to create the timeline? I don't recall that >>>> > being exposed via REST ... >>>> > >>>> > Cheers, >>>> > >>>> > /peter neubauer >>>> > >>>> > GTalk: neubauer.peter >>>> > Skype peter.neubauer >>>> > Phone +46 704 106975 >>>> > LinkedIn http://www.linkedin.com/in/neubauer >>>> > Twitter http://twitter.com/peterneubauer >>>> > >>>> > http://www.neo4j.org - Your high performance graph >>>> > database. >>>> > http://startupbootcamp.org/ - Öresund - Innovation happens HERE. >>>> > http://www.thoug
Re: [Neo4j] REST API & LuceneTimeline
Peter, Kind of. I see how I could do that server-side, but not how to insert elements into the index numerically (with ValueContext(val).indexNumeric()) or query by range ( .query(QueryContext.numericRange() ) via REST. Is this something that will require our writing a plugin to support, or is there currently some way to index and query numerically via the REST API? -- Matt Luongo Co-Founder, Scholr.ly On Wed, Jun 15, 2011 at 9:25 AM, Peter Neubauer wrote: > Yeah, > just checked with Mattias. There is no such index configuration, so > this does not work. I think you should use the numeric field in a > normal index for this, just like Rick points out. > > Does that make sense? > > /peter > > On Wed, Jun 15, 2011 at 3:03 PM, Matt Luongo wrote: >> Peter, >> >> I believe it was something like >> >> curl -X POST -H Accept:application/json -HContent-Type:application/json -d \ >> '{"name":"time", "config":{"type":"timeline","provider":"lucene"}}' \ >> http://localhost:7474/db/data/index/node >> >> curl -HContent-Type:application/json -X POST -d \ >> '"http://localhost:7474/db/data/node/0";' \ >> http://localhost:7474/db/data/index/node/time/timestamp/25 >> >> which gives a 500. >> -- >> Matt Luongo >> Co-Founder, Scholr.ly >> >> >> On Wed, Jun 15, 2011 at 8:55 AM, Rick Bullotta >> wrote: >>> >>> You really don't need a timeline index to do a timeline index, if that >>> makes sense. As mattias points out, it is just a convenient wrapper around >>> a plain lucene (neo) index. Just index the timestamp as a numeric field. >>> >>> >>> >>> - Reply message - >>> From: "Matt Luongo" >>> Date: Wed, Jun 15, 2011 8:48 am >>> Subject: [Neo4j] REST API & LuceneTimeline >>> To: "Neo4j user discussions" >>> >>> Peter, >>> >>> I've done a bit more research, and you're right- it isn't. However, the REST >>> api let's me create an index of type 'timeline'. The first time I try to >>> index a node, there's a 500 error (nullpointer) that stems from the index >>> not being created. I'd be happy to file a bug report. >>> >>> Anyway, we're trying to put together a plugin to expose timeline indexing >>> via REST. >>> >>> - Matt >>> On Jun 15, 2011 5:49 AM, "Peter Neubauer" >>> wrote: >>> > Matt, >>> > what URL are you using to create the timeline? I don't recall that >>> > being exposed via REST ... >>> > >>> > Cheers, >>> > >>> > /peter neubauer >>> > >>> > GTalk: neubauer.peter >>> > Skype peter.neubauer >>> > Phone +46 704 106975 >>> > LinkedIn http://www.linkedin.com/in/neubauer >>> > Twitter http://twitter.com/peterneubauer >>> > >>> > http://www.neo4j.org - Your high performance graph database. >>> > http://startupbootcamp.org/ - Öresund - Innovation happens HERE. >>> > http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party. >>> > >>> > >>> > >>> > On Mon, May 30, 2011 at 11:16 PM, Matt Luongo wrote: >>> >> Forgive me if this is a foolish question. I'm really excited about using >>> the >>> >> LuceneTimeline in our product. I see that I can create it via >>> >> "type":"timeline" in the REST interface. I'm not sure, though, how to add >>> >> nodes to the timeline- it seems like you add things to a timeline by >>> >> specifying just a timestamp, not key/value, but I can only find REST >>> >> examples for indexing nodes by key/value. Anyone care to share a code >>> >> snippet? >>> >> >>> >> -- >>> >> Matt Luongo >>> >> Co-Founder, Scholr.ly >>> >> ___ >>> >> Neo4j mailing list >>> >> User@lists.neo4j.org >>> >> https://lists.neo4j.org/mailman/listinfo/user >>> >> >>> > ___ >>> > Neo4j mailing list >>> > User@lists.neo4j.org >>> > https://lists.neo4j.org/mailman/listinfo/user >>> ___ >>> Neo4j mailing list >>> User@lists.neo4j.org >>> https://lists.neo4j.org/mailman/listinfo/user >> > ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] REST API & LuceneTimeline
I guess the other question is how I might accomplish range queries, using REST. -- Matt Luongo Co-Founder, Scholr.ly On Wed, Jun 15, 2011 at 9:05 AM, Matt Luongo wrote: > Rick, > > Is there a sensible way to do that while accessing the index via REST? > I'd prefer if I could create *and* access the index via the REST > interface, but just querying and inserting into the index would be > great. > > -- > Matt Luongo > Co-Founder, Scholr.ly > > > > On Wed, Jun 15, 2011 at 8:55 AM, Rick Bullotta > wrote: >> You really don't need a timeline index to do a timeline index, if that makes >> sense. As mattias points out, it is just a convenient wrapper around a >> plain lucene (neo) index. Just index the timestamp as a numeric field. >> >> >> >> - Reply message - >> From: "Matt Luongo" >> Date: Wed, Jun 15, 2011 8:48 am >> Subject: [Neo4j] REST API & LuceneTimeline >> To: "Neo4j user discussions" >> >> Peter, >> >> I've done a bit more research, and you're right- it isn't. However, the REST >> api let's me create an index of type 'timeline'. The first time I try to >> index a node, there's a 500 error (nullpointer) that stems from the index >> not being created. I'd be happy to file a bug report. >> >> Anyway, we're trying to put together a plugin to expose timeline indexing >> via REST. >> >> - Matt >> On Jun 15, 2011 5:49 AM, "Peter Neubauer" >> wrote: >>> Matt, >>> what URL are you using to create the timeline? I don't recall that >>> being exposed via REST ... >>> >>> Cheers, >>> >>> /peter neubauer >>> >>> GTalk: neubauer.peter >>> Skype peter.neubauer >>> Phone +46 704 106975 >>> LinkedIn http://www.linkedin.com/in/neubauer >>> Twitter http://twitter.com/peterneubauer >>> >>> http://www.neo4j.org - Your high performance graph database. >>> http://startupbootcamp.org/ - Öresund - Innovation happens HERE. >>> http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party. >>> >>> >>> >>> On Mon, May 30, 2011 at 11:16 PM, Matt Luongo wrote: >>>> Forgive me if this is a foolish question. I'm really excited about using >> the >>>> LuceneTimeline in our product. I see that I can create it via >>>> "type":"timeline" in the REST interface. I'm not sure, though, how to add >>>> nodes to the timeline- it seems like you add things to a timeline by >>>> specifying just a timestamp, not key/value, but I can only find REST >>>> examples for indexing nodes by key/value. Anyone care to share a code >>>> snippet? >>>> >>>> -- >>>> Matt Luongo >>>> Co-Founder, Scholr.ly >>>> ___ >>>> Neo4j mailing list >>>> User@lists.neo4j.org >>>> https://lists.neo4j.org/mailman/listinfo/user >>>> >>> ___ >>> Neo4j mailing list >>> User@lists.neo4j.org >>> https://lists.neo4j.org/mailman/listinfo/user >> ___ >> Neo4j mailing list >> User@lists.neo4j.org >> https://lists.neo4j.org/mailman/listinfo/user >> > ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] REST API & LuceneTimeline
Rick, Is there a sensible way to do that while accessing the index via REST? I'd prefer if I could create *and* access the index via the REST interface, but just querying and inserting into the index would be great. -- Matt Luongo Co-Founder, Scholr.ly On Wed, Jun 15, 2011 at 8:55 AM, Rick Bullotta wrote: > You really don't need a timeline index to do a timeline index, if that makes > sense. As mattias points out, it is just a convenient wrapper around a > plain lucene (neo) index. Just index the timestamp as a numeric field. > > > > - Reply message - > From: "Matt Luongo" > Date: Wed, Jun 15, 2011 8:48 am > Subject: [Neo4j] REST API & LuceneTimeline > To: "Neo4j user discussions" > > Peter, > > I've done a bit more research, and you're right- it isn't. However, the REST > api let's me create an index of type 'timeline'. The first time I try to > index a node, there's a 500 error (nullpointer) that stems from the index > not being created. I'd be happy to file a bug report. > > Anyway, we're trying to put together a plugin to expose timeline indexing > via REST. > > - Matt > On Jun 15, 2011 5:49 AM, "Peter Neubauer" > wrote: >> Matt, >> what URL are you using to create the timeline? I don't recall that >> being exposed via REST ... >> >> Cheers, >> >> /peter neubauer >> >> GTalk: neubauer.peter >> Skype peter.neubauer >> Phone +46 704 106975 >> LinkedIn http://www.linkedin.com/in/neubauer >> Twitter http://twitter.com/peterneubauer >> >> http://www.neo4j.org - Your high performance graph database. >> http://startupbootcamp.org/ - Öresund - Innovation happens HERE. >> http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party. >> >> >> >> On Mon, May 30, 2011 at 11:16 PM, Matt Luongo wrote: >>> Forgive me if this is a foolish question. I'm really excited about using > the >>> LuceneTimeline in our product. I see that I can create it via >>> "type":"timeline" in the REST interface. I'm not sure, though, how to add >>> nodes to the timeline- it seems like you add things to a timeline by >>> specifying just a timestamp, not key/value, but I can only find REST >>> examples for indexing nodes by key/value. Anyone care to share a code >>> snippet? >>> >>> -- >>> Matt Luongo >>> Co-Founder, Scholr.ly >>> ___ >>> Neo4j mailing list >>> User@lists.neo4j.org >>> https://lists.neo4j.org/mailman/listinfo/user >>> >> ___ >> Neo4j mailing list >> User@lists.neo4j.org >> https://lists.neo4j.org/mailman/listinfo/user > ___ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] REST API & LuceneTimeline
Peter, I believe it was something like curl -X POST -H Accept:application/json -HContent-Type:application/json -d \ '{"name":"time", "config":{"type":"timeline","provider":"lucene"}}' \ http://localhost:7474/db/data/index/node curl -HContent-Type:application/json -X POST -d \ '"http://localhost:7474/db/data/node/0";' \ http://localhost:7474/db/data/index/node/time/timestamp/25 which gives a 500. -- Matt Luongo Co-Founder, Scholr.ly On Wed, Jun 15, 2011 at 8:55 AM, Rick Bullotta wrote: > > You really don't need a timeline index to do a timeline index, if that makes > sense. As mattias points out, it is just a convenient wrapper around a plain > lucene (neo) index. Just index the timestamp as a numeric field. > > > > - Reply message - > From: "Matt Luongo" > Date: Wed, Jun 15, 2011 8:48 am > Subject: [Neo4j] REST API & LuceneTimeline > To: "Neo4j user discussions" > > Peter, > > I've done a bit more research, and you're right- it isn't. However, the REST > api let's me create an index of type 'timeline'. The first time I try to > index a node, there's a 500 error (nullpointer) that stems from the index > not being created. I'd be happy to file a bug report. > > Anyway, we're trying to put together a plugin to expose timeline indexing > via REST. > > - Matt > On Jun 15, 2011 5:49 AM, "Peter Neubauer" > wrote: > > Matt, > > what URL are you using to create the timeline? I don't recall that > > being exposed via REST ... > > > > Cheers, > > > > /peter neubauer > > > > GTalk: neubauer.peter > > Skype peter.neubauer > > Phone +46 704 106975 > > LinkedIn http://www.linkedin.com/in/neubauer > > Twitter http://twitter.com/peterneubauer > > > > http://www.neo4j.org - Your high performance graph database. > > http://startupbootcamp.org/ - Öresund - Innovation happens HERE. > > http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party. > > > > > > > > On Mon, May 30, 2011 at 11:16 PM, Matt Luongo wrote: > >> Forgive me if this is a foolish question. I'm really excited about using > the > >> LuceneTimeline in our product. I see that I can create it via > >> "type":"timeline" in the REST interface. I'm not sure, though, how to add > >> nodes to the timeline- it seems like you add things to a timeline by > >> specifying just a timestamp, not key/value, but I can only find REST > >> examples for indexing nodes by key/value. Anyone care to share a code > >> snippet? > >> > >> -- > >> Matt Luongo > >> Co-Founder, Scholr.ly > >> ___ > >> Neo4j mailing list > >> User@lists.neo4j.org > >> https://lists.neo4j.org/mailman/listinfo/user > >> > > ___ > > Neo4j mailing list > > User@lists.neo4j.org > > https://lists.neo4j.org/mailman/listinfo/user > ___ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] REST API & LuceneTimeline
Peter, I've done a bit more research, and you're right- it isn't. However, the REST api let's me create an index of type 'timeline'. The first time I try to index a node, there's a 500 error (nullpointer) that stems from the index not being created. I'd be happy to file a bug report. Anyway, we're trying to put together a plugin to expose timeline indexing via REST. - Matt On Jun 15, 2011 5:49 AM, "Peter Neubauer" wrote: > Matt, > what URL are you using to create the timeline? I don't recall that > being exposed via REST ... > > Cheers, > > /peter neubauer > > GTalk: neubauer.peter > Skype peter.neubauer > Phone +46 704 106975 > LinkedIn http://www.linkedin.com/in/neubauer > Twitter http://twitter.com/peterneubauer > > http://www.neo4j.org - Your high performance graph database. > http://startupbootcamp.org/- Öresund - Innovation happens HERE. > http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party. > > > > On Mon, May 30, 2011 at 11:16 PM, Matt Luongo wrote: >> Forgive me if this is a foolish question. I'm really excited about using the >> LuceneTimeline in our product. I see that I can create it via >> "type":"timeline" in the REST interface. I'm not sure, though, how to add >> nodes to the timeline- it seems like you add things to a timeline by >> specifying just a timestamp, not key/value, but I can only find REST >> examples for indexing nodes by key/value. Anyone care to share a code >> snippet? >> >> -- >> Matt Luongo >> Co-Founder, Scholr.ly >> ___ >> Neo4j mailing list >> User@lists.neo4j.org >> https://lists.neo4j.org/mailman/listinfo/user >> > ___ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
[Neo4j] REST API & LuceneTimeline
Forgive me if this is a foolish question. I'm really excited about using the LuceneTimeline in our product. I see that I can create it via "type":"timeline" in the REST interface. I'm not sure, though, how to add nodes to the timeline- it seems like you add things to a timeline by specifying just a timestamp, not key/value, but I can only find REST examples for indexing nodes by key/value. Anyone care to share a code snippet? -- Matt Luongo Co-Founder, Scholr.ly ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] Indexing vs 1.5 million relationships
Thanks Rick! I totally forgot about transaction cost. Sounds like it'll be index based. -- Matt Luongo Co-Founder, Scholr.ly On Sat, May 14, 2011 at 4:12 PM, Rick Bullotta wrote: > If you'll be adding/removing nodes constantly, definitely use Lucene > indexing rather than a zillion relationships on a single node. You'll > create a big synchronization (performance) issue if you do. If you are > "bulk loading" your graph, then I wouldn't worry about it. > > > From: user-boun...@lists.neo4j.org [user-boun...@lists.neo4j.org] On > Behalf Of Matt Luongo [m...@scholr.ly] > Sent: Saturday, May 14, 2011 11:19 AM > To: user@lists.neo4j.org > Subject: [Neo4j] Indexing vs 1.5 million relationships > > I'm dealing with a pretty common scenario- my nodes need to have a > type hierarchy applied to them. The type hierarchy exists in the graph, and > the leaves of the type tree have relationships to each instance of the > type. > However, most of my graph will be instances of a type. > > What I'm wondering is- would it be more performant to build a > type hierarchy and retrieve instances through an index, or to stick with > this architecture, and suffer 1.5 million relationships to a single type > node? > > Thanks in advance, > > -- > Matt Luongo > Co-Founder, Scholr.ly > ___ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > ___ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
[Neo4j] Indexing vs 1.5 million relationships
I'm dealing with a pretty common scenario- my nodes need to have a type hierarchy applied to them. The type hierarchy exists in the graph, and the leaves of the type tree have relationships to each instance of the type. However, most of my graph will be instances of a type. What I'm wondering is- would it be more performant to build a type hierarchy and retrieve instances through an index, or to stick with this architecture, and suffer 1.5 million relationships to a single type node? Thanks in advance, -- Matt Luongo Co-Founder, Scholr.ly ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user