SDN Cypher @Query annotated query doesn't recognize input parameters

202 views
Skip to first unread message

Nghia Doan

unread,
Nov 29, 2012, 9:37:18 AM11/29/12
to ne...@googlegroups.com
Hi all,

I am using Neo4j 1.8, SDN 2.1.0 RELASE and have some trouble with this query

@Query("START d=node:DepartmentCode(code={0})  MATCH d<-[:HAS_PROVINCE_LEVEL|HAS_DISTRICT_LEVEL|HAS_WARD_LEVEL]-l<-[:IN_PROVINCE|IN_DISTRICT|IN_WARD]-a<-[:HAS_COMPANY_ADDRESS]-c-[:HAS_BUSINESS_TYPE]->bt, c-[:HAS_COMPANY_LICENSE]->lc RETURN bt.name AS type,  LENGTH(FILTER(v IN COLLECT(lc.validFrom) : v >= {1} AND v < {2})) AS numberOfNewLicenses, LENGTH(FILTER(v IN COLLECT(lc.validFrom) : v >= {3} AND v < {2})) AS numberOfTotalLicenses")

public Iterable<LicenseInfo> getDepartmentLicenseInfo(String departmentCode, Long startPeriod, Long endPeriod, Long yearStart);

Exception in thread "main" org.neo4j.cypher.ParameterNotFoundException: Expected a parameter named 1
 at org
.neo4j.cypher.internal.commands.ParameterExpression$$anonfun$compute$3.apply(Expression.scala:262)
 at org
.neo4j.cypher.internal.commands.ParameterExpression$$anonfun$compute$3.apply(Expression.scala:262)
 at scala
.collection.MapLike$class.getOrElse(MapLike.scala:122)
 at scala
.collection.mutable.HashMap.getOrElse(HashMap.scala:43)
 at org
.neo4j.cypher.internal.commands.ParameterExpression.compute(Expression.scala:262)
 at org
.neo4j.cypher.internal.commands.ParameterExpression.apply(Expression.scala:267)
 at org
.neo4j.cypher.internal.commands.ComparablePredicate.isMatch(ComparablePredicate.scala:33)
 at org
.neo4j.cypher.internal.commands.And.isMatch(Predicate.scala:73)
 at org
.neo4j.cypher.internal.commands.FilterFunction$$anonfun$compute$4.apply(Functions.scala:233)
 at org
.neo4j.cypher.internal.commands.FilterFunction$$anonfun$compute$4.apply(Functions.scala:233)
 at scala
.collection.TraversableLike$$anonfun$filter$1.apply(TraversableLike.scala:213)
 at scala
.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
 at scala
.collection.immutable.List.foreach(List.scala:45)
 at scala
.collection.TraversableLike$class.filter(TraversableLike.scala:212)
 at scala
.collection.immutable.List.filter(List.scala:45)
 at org
.neo4j.cypher.internal.commands.FilterFunction.compute(Functions.scala:233)
 at org
.neo4j.cypher.internal.commands.FilterFunction.compute(Functions.scala:229)
 at org
.neo4j.cypher.internal.commands.NullInNullOutExpression.compute(Functions.scala:35)
 at org
.neo4j.cypher.internal.commands.Expression$$anonfun$apply$1.apply(Expression.scala:30)
 at scala
.collection.MapLike$class.getOrElse(MapLike.scala:122)
 at org
.neo4j.cypher.internal.pipes.ExecutionContext.getOrElse(Pipe.scala:97)
 at org
.neo4j.cypher.internal.commands.Expression.apply(Expression.scala:30)
 at org
.neo4j.cypher.internal.commands.NullInNullOutExpression.compute(Functions.scala:33)
 at org
.neo4j.cypher.internal.commands.Expression$$anonfun$apply$1.apply(Expression.scala:30)
 at scala
.collection.MapLike$class.getOrElse(MapLike.scala:122)
 at org
.neo4j.cypher.internal.pipes.ExecutionContext.getOrElse(Pipe.scala:97)
 at org
.neo4j.cypher.internal.commands.Expression.apply(Expression.scala:30)
 at org
.neo4j.cypher.internal.pipes.ExtractPipe$$anonfun$createResults$1$$anonfun$apply$1.apply(ExtractPipe.scala:38)
 at org
.neo4j.cypher.internal.pipes.ExtractPipe$$anonfun$createResults$1$$anonfun$apply$1.apply(ExtractPipe.scala:38)
 at scala
.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
 at scala
.collection.immutable.List.foreach(List.scala:45)
 at org
.neo4j.cypher.internal.pipes.ExtractPipe$$anonfun$createResults$1.apply(ExtractPipe.scala:38)
 at org
.neo4j.cypher.internal.pipes.ExtractPipe$$anonfun$createResults$1.apply(ExtractPipe.scala:37)
 at scala
.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194)
 at scala
.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194)
 at scala
.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:60)
 at scala
.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:44)
 at scala
.collection.TraversableLike$class.map(TraversableLike.scala:194)
 at scala
.collection.mutable.ArrayBuffer.map(ArrayBuffer.scala:44)
 at org
.neo4j.cypher.internal.pipes.ExtractPipe.createResults(ExtractPipe.scala:37)
 at org
.neo4j.cypher.internal.pipes.ColumnFilterPipe.createResults(ColumnFilterPipe.scala:39)
 at org
.neo4j.cypher.internal.executionplan.ExecutionPlanImpl$$anonfun$4$$anonfun$apply$2.apply(ExecutionPlanImpl.scala:95)
 at org
.neo4j.cypher.internal.executionplan.ExecutionPlanImpl$$anonfun$4$$anonfun$apply$2.apply(ExecutionPlanImpl.scala:95)
 at org
.neo4j.cypher.PipeExecutionResult.immutableResult(PipeExecutionResult.scala:37)
 at org
.neo4j.cypher.PipeExecutionResult.iterator(PipeExecutionResult.scala:153)
 at org
.neo4j.cypher.PipeExecutionResult.hasNext(PipeExecutionResult.scala:155)
 at scala
.collection.Iterator$$anon$19.hasNext(Iterator.scala:334)
 at scala
.collection.JavaConversions$IteratorWrapper.hasNext(JavaConversions.scala:562)
 at org
.neo4j.helpers.collection.IteratorWrapper.hasNext(IteratorWrapper.java:42)
 at org
.neo4j.helpers.collection.IteratorUtil.addToCollection(IteratorUtil.java:322)
 at org
.neo4j.helpers.collection.IteratorUtil.addToCollection(IteratorUtil.java:341)
 at org
.neo4j.helpers.collection.IteratorUtil.asCollection(IteratorUtil.java:426)
 at com
.iesvn.service.neo4j.CollectionUtils.asList(CollectionUtils.java:16)
 at com
.iesvn.service.domain.report.foodpoisoning.FoodPoisoningReport678.getLicenseInfo(FoodPoisoningReport678.java:758)
 at com
.iesvn.service.domain.report.foodpoisoning.FoodPoisoningReport678.createXmlContent(FoodPoisoningReport678.java:162)
 at com
.iesvn.test.TestService.testFoodSafetyReport(TestService.java:427)
 at com
.iesvn.test.TestService.run(TestService.java:459)
 at com
.iesvn.test.App.runTestService(App.java:40)
 at com
.iesvn.test.App.main(App.java:23)


My other queries, written in pretty much same syntax, has no issues. I think that using parameters inside of a FILTER clause causes this problem.

Thank you in advance for your help.

Nghia Doan

Lasse Westh-Nielsen

unread,
Nov 29, 2012, 12:08:24 PM11/29/12
to ne...@googlegroups.com
Nghia,

I think you are right. Could you raise an issue here:
https://jira.springsource.org/browse/DATAGRAPH

Meanwhile, try working around that using named parameters:

@Query("start mom=node({id}) match mom-[:CHILD]->child where
child.eyeColour in {foo} return child")
Set<Child> childrenByColour(@Param("id") long id,
@Param("foo")long[] colours);

Regards,

Lasse
> --
>
>

Nghia Doan

unread,
Nov 29, 2012, 1:28:05 PM11/29/12
to ne...@googlegroups.com, la...@neotechnology.com
Hi Lasse,

Done. 

I gave some more experiment results.

Nghia Doan

Nghia Doan

unread,
Nov 29, 2012, 1:30:05 PM11/29/12
to ne...@googlegroups.com, la...@neotechnology.com
I would like also to note that the explicit named parameter like {startPeriod} doesn't work either.

Cost me two hours to try all work-arounds imaginable by myself.

Nghia Doan

On Friday, November 30, 2012 12:08:24 AM UTC+7, Lasse Westh-Nielsen wrote:

Michael Hunger

unread,
Dec 14, 2012, 7:16:54 AM12/14/12
to ne...@googlegroups.com
This is an issue related to Cypher I think, please try to use Neo4j 1.9.M02 and report back if it worked for you.

Bob Wilson

unread,
Mar 5, 2013, 11:44:10 AM3/5/13
to ne...@googlegroups.com
Can you query on the __type__ property through Cypher? We are using 1.8.1 and running this Cypher query that does not work: start n=node:FacilityNode(__type__='com.curaspan.providerbank.domain.FacilityNode') return n;

I can see a node on the graph as this: Node[10000]{latitude:38.0849,dbid:16356,longitude:81.86,name:"Boone Nursing and Rehab Center",__type__:"com.curaspan.providerbank.domain.FacilityNode"}

Thank you.

| Node[10000]{latitude:38.0849,dbid:16356,longitude:81.86,name:"Boone Nursing and Rehab Center",__type__:"com.curaspan.providerbank.domain.FacilityNode"}

Michael Hunger

unread,
Mar 5, 2013, 12:04:22 PM3/5/13
to ne...@googlegroups.com
The index name is __types__ so:

start n=node:__types__(className='com.curaspan.providerbank.domain.FacilityNode') return n;


--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Nghia Doan

unread,
Mar 5, 2013, 11:06:24 PM3/5/13
to ne...@googlegroups.com
Michael is right (as always :-)). In addition if you use TypeAlias, it's going to be shorter:

start n=node:__types__(className='FacilityNode') return n;

You received this message because you are subscribed to a topic in the Google Groups "Neo4j" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/neo4j/G76tbCjV6ME/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to neo4j+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages