Anormcypher 0.80,Scala 2.11.7
我试图通过使用'AND NOT (value.title IN 'item1','item2'‘)从循环结果集中排除项目列表。
我正在运行的cypher查询可以在neo4j控制台中运行,但是当我尝试使用anormcypher执行相同的查询时,它不会排除item1和item2。查询如下:
MATCH (c:Item)-[:INCLUDES_TERM]-(t:Term),(b:Box)-[:CONTAINS_TERM]-(t),
(b)-[r:IS_ABOUT_THING]-(thm:Thing)
where c.name = 'aName'
AND NOT (thm.title IN [('item1','item2')])
AND b.date >= 1443657600000 AND b.date <= 1443657700000
return DISTINCT(thm.title) as thing, count(b) as amount
order by amount desc LIMIT 50在neo4j控制台中,此cypher查询将返回一个过滤掉item1和item2的结果。
如果我使用anormcypher从scala运行查询,item1和item2将不会从结果中过滤掉。代码如下:
val exclusions:String = "'item1','item2'"
val name = "aName"
val startDate = "1443657600000"
val endDate = "1443657700000"
val cypherQuery = Cypher("""MATCH (c:Item)-[:INCLUDES_TERM]-(t:Term),(b:Box)-[:CONTAINS_TERM]-(t),
(b)-[r:IS_ABOUT_THING]-(thm:Thing)
where c.name = {item}
AND NOT (thm.title IN [{exclusions}])
AND b.date >= {startDate} AND b.date <= {endDate}
return DISTINCT(thm.title) as thing, count(b) as amount
order by amount desc LIMIT 50"""
).on("item" -> name, "startDate" -> startDate, "endDate" -> endDate, "exclusions" -> exclusions)
val resultList = cypherQuery.apply()为什么这个查询可以在neo4j控制台中使用,但不能在scala中使用anormcypher?
发布于 2016-03-13 06:02:20
exclusions参数应该是字符串数组,而不是嵌入到数组中的单个字符串。试试这个:
val exclusions: Array[String] = Array("item1", "item2")
val name = "aName"
val startDate = "1443657600000"
val endDate = "1443657700000"
val cypherQuery = Cypher("""MATCH (c:Item)-[:INCLUDES_TERM]-(t:Term),(b:Box)-[:CONTAINS_TERM]-(t),
(b)-[r:IS_ABOUT_THING]-(thm:Thing)
where c.name = {item}
AND NOT (thm.title IN {exclusions})
AND b.date >= {startDate} AND b.date <= {endDate}
return DISTINCT(thm.title) as thing, count(b) as amount
order by amount desc LIMIT 50"""
).on("item" -> name, "startDate" -> startDate, "endDate" -> endDate, "exclusions" -> exclusions)
val resultList = cypherQuery.apply()https://stackoverflow.com/questions/35957719
复制相似问题