0

异常密码 0.80,Scala 2.11.7

我试图通过使用'AND NOT(value.title IN ['item1','item2']'从密码结果集中排除项目列表。

我正在运行的密码查询在 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 控制台中,此密码查询将返回过滤掉 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 控制台中有效,但在使用 anormcypher 的 scala 中无效?

4

1 回答 1

1

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()
于 2016-03-12T22:02:20.487 回答