Cypher query error with "NOT IN expressions" #398

Closed
giamai opened this Issue Jan 3, 2013 · 4 comments

Comments

Projects
None yet
3 participants

giamai commented Jan 3, 2013

Dear Neo4j team,
I have a issue when i'm trying to use NOT IN expressions

This is my use case:

- The first query, i get nodes that have relationship with cypher
start cypher=node(4) 
match cypher-[:KNOWS]-friends 
return friends

Expect result: node 2 and node 5
Actual result: node 2 and node 5. This query run pretty good.

- The second query, i inherit the first query but i want to exclude node 5  

start cypher=node(4) 
match cypher-[:KNOWS]-friends 
where NOT (ID(friends) IN [5]) 
return friends

Expect result: node 2
Actual result: "Error: java.lang.RuntimeException: java.lang.RuntimeException"

Please try above use cases on http://tinyurl.com/bn35krt 

Thanks!
Gia
Contributor

peterneubauer commented Jan 3, 2013

Thanks for raising the issue, here is the stack trace for http://console.neo4j.org/r/qlu6g8 :

match cypher-[:KNOWS]->friends
2013-01-03T10:56:26+00:00 app[web.1]: where NOT (ID(friends) IN [5])
2013-01-03T10:56:26+00:00 app[web.1]: return friends
2013-01-03T10:56:26+00:00 app[web.1]: java.lang.RuntimeException: java.lang.RuntimeException
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.community.console.CypherQueryExecutor.createTimedResults(CypherQueryExecutor.java:209)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.community.console.CypherQueryExecutor.cypherQuery(CypherQueryExecutor.java:172)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.community.console.CypherQueryExecutor.cypherQuery(CypherQueryExecutor.java:162)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.community.console.Neo4jService.cypherQuery(Neo4jService.java:97)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.community.console.ConsoleService.execute(ConsoleService.java:107)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.community.console.ConsoleApplication$2.doHandle(ConsoleApplication.java:46)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.community.console.Route.handle(Route.java:37)
2013-01-03T10:56:26+00:00 heroku[router]: at=info method=POST path=/console/cypher host=console.neo4j.org fwd=212.162.171.110 dyno=web.1 queue=0 wait=0ms connect=1ms service=18ms status=200 bytes=200
2013-01-03T10:56:26+00:00 app[web.1]: at spark.webserver.MatcherFilter.doFilter(MatcherFilter.java:135)
2013-01-03T10:56:26+00:00 app[web.1]: at spark.servlet.SparkFilter.doFilter(SparkFilter.java:82)
2013-01-03T10:56:26+00:00 app[web.1]: at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1323)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.community.console.GuardingRequestFilter.doFilter(GuardingRequestFilter.java:59)
2013-01-03T10:56:26+00:00 app[web.1]: at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1323)
2013-01-03T10:56:26+00:00 app[web.1]: at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:474)
2013-01-03T10:56:26+00:00 app[web.1]: at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
2013-01-03T10:56:26+00:00 app[web.1]: at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:517)
2013-01-03T10:56:26+00:00 app[web.1]: at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
2013-01-03T10:56:26+00:00 app[web.1]: at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:935)
2013-01-03T10:56:26+00:00 app[web.1]: at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:404)
2013-01-03T10:56:26+00:00 app[web.1]: at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:184)
2013-01-03T10:56:26+00:00 app[web.1]: at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:870)
2013-01-03T10:56:26+00:00 app[web.1]: at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
2013-01-03T10:56:26+00:00 app[web.1]: at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:47)
2013-01-03T10:56:26+00:00 app[web.1]: at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
2013-01-03T10:56:26+00:00 app[web.1]: at org.eclipse.jetty.server.Server.handle(Server.java:346)
2013-01-03T10:56:26+00:00 app[web.1]: at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:596)
2013-01-03T10:56:26+00:00 app[web.1]: at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:1068)
2013-01-03T10:56:26+00:00 app[web.1]: at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:807)
2013-01-03T10:56:26+00:00 app[web.1]: at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:220)
2013-01-03T10:56:26+00:00 app[web.1]: at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:426)
2013-01-03T10:56:26+00:00 app[web.1]: at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:520)
2013-01-03T10:56:26+00:00 app[web.1]: at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:40)
2013-01-03T10:56:26+00:00 app[web.1]: at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:528)
2013-01-03T10:56:26+00:00 app[web.1]: at java.lang.Thread.run(Thread.java:636)
2013-01-03T10:56:26+00:00 app[web.1]: Caused by: java.lang.RuntimeException
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.cypher.internal.pipes.matching.MiniMap.newWith(ExpanderStep.scala:167)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.cypher.internal.pipes.matching.MiniMap.newWith(ExpanderStep.scala:150)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.cypher.internal.commands.InCollection$$anonfun$isMatch$1.apply(InCollection.scala:38)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.cypher.internal.commands.InCollection$$anonfun$isMatch$1.apply(InCollection.scala:38)
2013-01-03T10:56:26+00:00 app[web.1]: at scala.collection.LinearSeqOptimized$class.exists(LinearSeqOptimized.scala:79)
2013-01-03T10:56:26+00:00 app[web.1]: at scala.collection.immutable.List.exists(List.scala:45)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.cypher.internal.commands.AnyInCollection$$anonfun$seqMethod$2.apply(InCollection.scala:72)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.cypher.internal.commands.AnyInCollection$$anonfun$seqMethod$2.apply(InCollection.scala:72)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.cypher.internal.commands.InCollection.isMatch(InCollection.scala:38)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.cypher.internal.commands.Not.isMatch(Predicate.scala:112)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.cypher.internal.commands.And.isMatch(Predicate.scala:78)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.cypher.internal.pipes.matching.FilteringIterable$FilteringIterator.spoolToNextInLine(FilteringIterable.scala:55)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.cypher.internal.pipes.matching.FilteringIterable$FilteringIterator.(FilteringIterable.scala:34)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.cypher.internal.pipes.matching.FilteringIterable.iterator(FilteringIterable.scala:72)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.cypher.internal.pipes.matching.FilteringIterable.iterator(FilteringIterable.scala:27)
2013-01-03T10:56:26+00:00 app[web.1]: at scala.collection.JavaConversions$IterableWrapperTrait$class.iterator(JavaConversions.scala:557)
2013-01-03T10:56:26+00:00 app[web.1]: at scala.collection.JavaConversions$IterableWrapper.iterator(JavaConversions.scala:583)
2013-01-03T10:56:26+00:00 app[web.1]: at scala.collection.JavaConversions$IterableWrapper.iterator(JavaConversions.scala:583)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.kernel.impl.traversal.TraversalBranchWithState.expandRelationshipsWithoutChecks(TraversalBranchWithState.java:70)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.kernel.impl.traversal.TraversalBranchImpl.expandRelationships(TraversalBranchImpl.java:104)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.kernel.impl.traversal.StartNodeTraversalBranch.next(StartNodeTraversalBranch.java:47)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.kernel.impl.traversal.AsOneStartBranch.next(AsOneStartBranch.java:100)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.kernel.PreorderDepthFirstSelector.next(PreorderDepthFirstSelector.java:52)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.kernel.impl.traversal.TraverserIterator.fetchNextOrNull(TraverserIterator.java:65)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.kernel.impl.traversal.TraverserIterator.fetchNextOrNull(TraverserIterator.java:34)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.helpers.collection.PrefetchingIterator.hasNext(PrefetchingIterator.java:55)
2013-01-03T10:56:26+00:00 app[web.1]: at scala.collection.JavaConversions$JIteratorWrapper.hasNext(JavaConversions.scala:574)
2013-01-03T10:56:26+00:00 app[web.1]: at scala.collection.Iterator$$anon$21.hasNext(Iterator.scala:371)
2013-01-03T10:56:26+00:00 app[web.1]: at scala.collection.Iterator$$anon$21.hasNext(Iterator.scala:371)
2013-01-03T10:56:26+00:00 app[web.1]: at scala.collection.Iterator$$anon$22.hasNext(Iterator.scala:388)
2013-01-03T10:56:26+00:00 app[web.1]: at scala.collection.Iterator$$anon$19.hasNext(Iterator.scala:334)
2013-01-03T10:56:26+00:00 app[web.1]: at scala.collection.Iterator$$anon$19.hasNext(Iterator.scala:334)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.cypher.internal.ClosingIterator$$anonfun$hasNext$1.apply$mcZ$sp(ClosingIterator.scala:36)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.cypher.internal.ClosingIterator$$anonfun$hasNext$1.apply(ClosingIterator.scala:35)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.cypher.internal.ClosingIterator$$anonfun$hasNext$1.apply(ClosingIterator.scala:35)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.cypher.internal.ClosingIterator.failIfThrows(ClosingIterator.scala:87)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.cypher.internal.ClosingIterator.hasNext(ClosingIterator.scala:35)
2013-01-03T10:56:26+00:00 app[web.1]: at scala.collection.Iterator$class.foreach(Iterator.scala:660)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.cypher.internal.ClosingIterator.foreach(ClosingIterator.scala:31)
2013-01-03T10:56:26+00:00 app[web.1]: at scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)
2013-01-03T10:56:26+00:00 app[web.1]: at scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:128)
2013-01-03T10:56:26+00:00 app[web.1]: at scala.collection.TraversableOnce$class.toList(TraversableOnce.scala:242)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.cypher.internal.ClosingIterator.toList(ClosingIterator.scala:31)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.cypher.PipeExecutionResult.createTimedResults(PipeExecutionResult.scala:73)
2013-01-03T10:56:26+00:00 app[web.1]: at sun.reflect.GeneratedMethodAccessor11.invoke(Unknown Source)
2013-01-03T10:56:26+00:00 app[web.1]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2013-01-03T10:56:26+00:00 app[web.1]: at java.lang.reflect.Method.invoke(Method.java:616)
2013-01-03T10:56:26+00:00 app[web.1]: at org.neo4j.community.console.CypherQueryExecutor.createTimedResults(CypherQueryExecutor.java:202)
2013-01-03T10:56:26+00:00 app[web.1]: ... 32 more

Member

jexp commented Jan 3, 2013

Duplicate of #390

@jexp jexp closed this Jan 3, 2013

Member

jexp commented Jan 3, 2013

As a workaround please use an expression that contains ID(friends) before the IN clause.

see: http://console.neo4j.org/r/92ce17

start cypher=node(4) 
match cypher-[:KNOWS]->friends 
where ID(friends)>=0 AND NOT (ID(friends) IN [5]) 
return friends

giamai commented Jan 3, 2013

Thanks Jexp and Peter Neubauer for your fast responses.
I was try to use an expressions as your suggestion and it works pretty good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment