当使用带有null值的索引属性时,Neo4j 2.2 NullPointerException

时间:2015-05-28 18:20:09

标签: neo4j

我们在Windows Server 2008 R2上使用JRE 1.7.0_79运行Neo4j。

当执行某些符合索引的查询时,我们得到NullPointerException

查询如下所示:

MATCH (assignee)<-[:ASSIGNED_TO]-(task:Task)-[instanceOfRel:INSTANCE_OF]->(distribution:Distribution) WITH assignee, task, distribution, instanceOfRel.CountryUid AS applicableCountryUid OPTIONAL MATCH (country:Country) WHERE country.Uid = applicableCountryUid RETURN assignee, task, distribution, country

如果WHEREapplicableCountryUid,则null子句的查询失败。

如果从架构中删除索引,查询将正常工作。

完整异常堆栈的部分提取是:

"Received an unexpected HTTP status when executing the request.The response status was: 400 Bad RequestThe response from Neo4j (which might include useful detail!) was: {  
"exception" : "NullPointerException",  "fullname" : "java.lang.NullPointerException",  
"stackTrace" : [ "org.neo4j.kernel.api.impl.index.LuceneDocumentStructure$ValueEncoding$2.canEncode(LuceneDocumentStructure.java:90)", 
"org.neo4j.kernel.api.impl.index.LuceneDocumentStructure.newQuery(LuceneDocumentStructure.java:219)", 
"org.neo4j.kernel.api.impl.index.LuceneIndexAccessorReader.lookup(LuceneIndexAccessorReader.java:96)", 
"org.neo4j.kernel.impl.api.store.DiskLayer.nodesGetFromIndexLookup(DiskLayer.java:601)", 
"org.neo4j.kernel.impl.api.store.CacheLayer.nodesGetFromIndexLookup(CacheLayer.java:349)", 
"org.neo4j.kernel.impl.api.StateHandlingStatementOperations.nodesGetFromIndexLookup(StateHandlingStatementOperations.java:591)",
 "org.neo4j.kernel.impl.api.ConstraintEnforcingEntityOperations.nodesGetFromIndexLookup(ConstraintEnforcingEntityOperations.java:210)",

这似乎不会影响早期2.1.x版Neo4j中的查询,但我们只看到2.2.0和2.2.2的这个问题。

是否存在使用索引而不重写查询的已知问题或解决方法?

1 个答案:

答案 0 :(得分:0)

applicableCountryUidnull时结果是否有意义? WHERE条款当时没有多大意义。

也许您可以过滤掉null个案例:

MATCH (assignee)<-[:ASSIGNED_TO]-(task:Task)-[instanceOfRel:INSTANCE_OF]->(distribution:Distribution)
WHERE has(instanceOfRel.CountryUid)
WITH assignee, task, distribution, instanceOfRel.CountryUid AS applicableCountryUid
OPTIONAL MATCH (country:Country)
WHERE country.Uid = applicableCountryUid
RETURN assignee, task, distribution, country