Neo4j 2.2 NullPointerException when using indexed property with null value - neo4j
We are running Neo4j on Windows Server 2008 R2 with JRE 1.7.0_79.
When executing certain queries which hit an index, we are getting a NullPointerException.
The query looks like the one below:
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
And the query fails on the WHERE clause if applicableCountryUid is null.
If the index is removed from the schema, the query will work fine.
A partial extract of the full exception stack is:
"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)",
This doesn't seem to affect the queries in earlier 2.1.x versions of Neo4j, but we are only seeing this issue with 2.2.0 and 2.2.2.
Is there a known issue or workarounds for working with the indices without rewriting queries?
Are the results meaningful when applicableCountryUid is null? The WHERE clause doesn't make much sense then.
Maybe you can filter out the null cases:
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
Related
Issue with new Cypher 3.1 head() function
We are using the new Cypher 3.1 head() function and are seeing some unusual (wrong?) behavior when it is used in a RETURN statement after an OPTIONAL MATCH command. It looks like values that the labels that don't match in the optional match negatively affect the data already collected from the head() perspective, while working as expected for the rest of the RETURN statement. Any ideas on what we're doing wrong or is this an unintended consequence in the Neo4j engine? MATCH (productLine:ProductLine)-[:CHILD]->(product:Product)-[:CHILD]->(application:Application)-[:MATCHES]->(:Rule {name: 'Tier-0 Application'}) WITH productLine, application OPTIONAL MATCH (application)-[mr:MATCHES]->(:Rule {name: 'Multiple Regions'}) WITH application, mr, productLine RETURN productLine.name AS ProductLine, head([(productLine)-[:PRODUCT_MANAGER]->(person:Person) | person.name]) AS ProductLineManager, mr.numServers, application.id AS AppId Here's what we see: ProductLine ProductLineManager mr.numServers AppId PL1 null null IN000041 PL2 LAST,FIRST 6 AP010024 PL3 LAST,FIRST 6 AP107752 PL4 LAST,FIRST 11 AP106560 PL5 null null AP012190
Looks like this is a bug related to pattern comprehension, not the head() function, when there are rows generated by an an OPTIONAL MATCH. I was able to reproduce the bug using the movies graph as a base. I created a bug for this on the Neo4j issues tracker, complete with examples. As a workaround, it looks like using DISTINCT on either the last WITH or on the RETURN may cause it to return expected results.
How do i check for a label in neo4j 2.1.2 when using a legacy index?
I just upgraded to Neo4j 2.1.2 from 2.0.1 and some of my cypher-queries stopped working. I am using a self-defined Lucene index to find the startnodes, navigate via a typed relationship (Partner_PartnerMeta) to a typed Node(PartnerTyp). After that i just return a subset of these nodes. My query previously used to check for the type of startnode (PartnerMeta). Since 2.1.2 the query START partnermeta = node:PartnerTyp_Meta("Namen:wilhelm*") MATCH (partner:PartnerTyp)-[:Partner_PartnerMeta]->(partnermeta:PartnerMeta) RETURN DISTINCT partner SKIP 0 LIMIT 10 results in Cannot add labels or properties on a node which is already bound (line 2, column 52) "MATCH (partner:PartnerTyp)-[:Partner_PartnerMeta]->(partnermeta:PartnerMeta)" ^ This error can be suppressed by omitting the ":PartnerMeta" part of the query. As the type of the node returned from the index hasn't been checked yet, i would like to verify that it is of the type "PartnerMeta" (maybe i am too paranoid that way). My question is: Is there a possibility to check for the type of node after the usage of START in combination with a legacy index?
This is a regression in Cypher 2.1.2 which will be fixed. It was an attempt to avoid invalid combinations of label checks. For now, can you try: START partnermeta = node:PartnerTyp_Meta("Namen:wilhelm*") MATCH (partner:PartnerTyp)-[:Partner_PartnerMeta]->(partnermeta) WHERE partnermeta:PartnerMeta RETURN DISTINCT partner SKIP 0 LIMIT 10
Neo4j Cypher query fails and return with an Unknown Error
I'm trying to build a Cypher query to test if a specific structure exists so I can relate dates to it. Running Neo4j 2.1.0-M01 on a Linux server, but the same issue occurred with Neo4j 2.0.1 We're starting with a clean database, 0 nodes. First I'm running this MATCH query to prove that it runs. Obviously this query is not going to return any nodes. But after creating the nodes, it will fail with an 'unknown error'. It seems like a bug to me, since a query with fewer nodes will return. Does anyone have suggestions how to rewrite this query for now? Sorry for the large amount of code in this post. Thanks, -Edwin Cypher Query: MATCH (c:Cluster{cluster_name:'mycluster',cluster_uuid:'7bd4f66d-5faf-11db-8d0d-000e0cba569c'}) ,(sc1:Controller{serialnumber:'7000610071',system_id:'1873784171',hostname:'node01',node_uuid:'7cd70205-66ae-11e0-a4a9-0deba859517d'}) ,(sc1)-[:IS_PART_OF_CLUSTER]->(c) ,(sc2:Controller{serialnumber:'7000606111',system_id:'1873778118',hostname:'node02',node_uuid:'b954f0a1-6682-11e0-b8a0-517da924923d'}) ,(sc2)-[:IS_PART_OF_CLUSTER]->(c) ,(sc3:Controller{serialnumber:'7000561878',system_id:'1873772083',hostname:'node03',node_uuid:'ac293586-6690-11e0-b8a0-517da924923d'}) ,(sc3)-[:IS_PART_OF_CLUSTER]->(c) ,(sc4:Controller{serialnumber:'800000075807',system_id:'1873784143',hostname:'node04',node_uuid:'e8d6c7e5-663e-11e0-b8a0-517da924923d'}) ,(sc4)-[:IS_PART_OF_CLUSTER]->(c) ,(sc5:Controller{serialnumber:'7000477261',system_id:'1873745662',hostname:'node05',node_uuid:'1d1ecc64-728c-11e0-bf0e-3d25383f7ed3'}) ,(sc5)-[:IS_PART_OF_CLUSTER]->(c) ,(sc6:Controller{serialnumber:'7000477273',system_id:'1873745654',hostname:'node06',node_uuid:'140fb0f9-728c-11e0-afeb-49fcf0b6e6c3'}) ,(sc6)-[:IS_PART_OF_CLUSTER]->(c) ,(sc7:Controller{serialnumber:'7000474908',system_id:'1873745665',hostname:'node07',node_uuid:'edbf9c62-728b-11e0-bf0e-3d25383f7ed3'}) ,(sc7)-[:IS_PART_OF_CLUSTER]->(c) ,(sc8:Controller{serialnumber:'7000474910',system_id:'1873745695',hostname:'node08',node_uuid:'20dbfe67-7832-11e0-afeb-49fcf0b6e6c3'}) ,(sc8)-[:IS_PART_OF_CLUSTER]->(c) ,(sc9:Controller{serialnumber:'7000609864',system_id:'1873802756',hostname:'node09',node_uuid:'a8b75397-6690-11e0-b8a0-517da924923d'}) ,(sc9)-[:IS_PART_OF_CLUSTER]->(c) ,(sc10:Controller{serialnumber:'7000610021',system_id:'1873791030',hostname:'node10',node_uuid:'f6cf0705-6670-11e0-b8a0-517da924923d'}) ,(sc10)-[:IS_PART_OF_CLUSTER]->(c) ,(sc11:Controller{serialnumber:'7000610057',system_id:'1873784128',hostname:'node11',node_uuid:'551b1bf8-663d-11e0-b8a0-517da924923d'}) ,(sc11)-[:IS_PART_OF_CLUSTER]->(c) ,(sc12:Controller{serialnumber:'7000609981',system_id:'1873778164',hostname:'node12',node_uuid:'f6062d6c-663e-11e0-9b53-cd0ece6aa2ce'}) ,(sc12)-[:IS_PART_OF_CLUSTER]->(c) ,(sc13:Controller{serialnumber:'7000610033',system_id:'1873778186',hostname:'node13',node_uuid:'ed0e61c5-6670-11e0-b07f-933da0385fdc'}) ,(sc13)-[:IS_PART_OF_CLUSTER]->(c) ,(sc14:Controller{serialnumber:'7000610069',system_id:'1873784175',hostname:'node14',node_uuid:'8623ea28-66ae-11e0-ab9d-5fdc7f30dee7'}) ,(sc14)-[:IS_PART_OF_CLUSTER]->(c) ,(sc15:Controller{serialnumber:'7000606109',system_id:'1873778197',hostname:'node15',node_uuid:'b4349a83-6682-11e0-ab9d-5fdc7f30dee7'}) ,(sc15)-[:IS_PART_OF_CLUSTER]->(c) ,(sc16:Controller{serialnumber:'7000610045',system_id:'1873784157',hostname:'node16',node_uuid:'67d80db8-663d-11e0-9b53-cd0ece6aa2ce'}) ,(sc16)-[:IS_PART_OF_CLUSTER]->(c) ,(sc17:Controller{serialnumber:'7001246085',system_id:'2014175904',hostname:'node19',node_uuid:'1c792588-ff4e-11db-94fe-3b91dd7dd242'}) ,(sc17)-[:IS_PART_OF_CLUSTER]->(c) ,(sc18:Controller{serialnumber:'7001246097',system_id:'2014176797',hostname:'node20',node_uuid:'3ae9e7ae-ff44-11db-864d-af2af862bba3'}) ,(sc18)-[:IS_PART_OF_CLUSTER]->(c) RETURN c,sc1,sc2,sc3,sc4,sc5,sc6,sc7,sc8,sc9,sc10,sc11,sc12,sc13,sc14,sc15,sc16,sc17,sc18 Rows returned: 0 Cypher Query for creating the nodes: CREATE (c:Cluster{cluster_name:'mycluster',cluster_uuid:'7bd4f66d-5faf-11db-8d0d-000e0cba569c'}) ,(sc1:Controller{serialnumber:'7000610071',system_id:'1873784171',hostname:'node01',node_uuid:'7cd70205-66ae-11e0-a4a9-0deba859517d'}) ,(sc1)-[:IS_PART_OF_CLUSTER]->(c) ,(sc2:Controller{serialnumber:'7000606111',system_id:'1873778118',hostname:'node02',node_uuid:'b954f0a1-6682-11e0-b8a0-517da924923d'}) ,(sc2)-[:IS_PART_OF_CLUSTER]->(c) ,(sc3:Controller{serialnumber:'7000561878',system_id:'1873772083',hostname:'node03',node_uuid:'ac293586-6690-11e0-b8a0-517da924923d'}) ,(sc3)-[:IS_PART_OF_CLUSTER]->(c) ,(sc4:Controller{serialnumber:'800000075807',system_id:'1873784143',hostname:'node04',node_uuid:'e8d6c7e5-663e-11e0-b8a0-517da924923d'}) ,(sc4)-[:IS_PART_OF_CLUSTER]->(c) ,(sc5:Controller{serialnumber:'7000477261',system_id:'1873745662',hostname:'node05',node_uuid:'1d1ecc64-728c-11e0-bf0e-3d25383f7ed3'}) ,(sc5)-[:IS_PART_OF_CLUSTER]->(c) ,(sc6:Controller{serialnumber:'7000477273',system_id:'1873745654',hostname:'node06',node_uuid:'140fb0f9-728c-11e0-afeb-49fcf0b6e6c3'}) ,(sc6)-[:IS_PART_OF_CLUSTER]->(c) ,(sc7:Controller{serialnumber:'7000474908',system_id:'1873745665',hostname:'node07',node_uuid:'edbf9c62-728b-11e0-bf0e-3d25383f7ed3'}) ,(sc7)-[:IS_PART_OF_CLUSTER]->(c) ,(sc8:Controller{serialnumber:'7000474910',system_id:'1873745695',hostname:'node08',node_uuid:'20dbfe67-7832-11e0-afeb-49fcf0b6e6c3'}) ,(sc8)-[:IS_PART_OF_CLUSTER]->(c) ,(sc9:Controller{serialnumber:'7000609864',system_id:'1873802756',hostname:'node09',node_uuid:'a8b75397-6690-11e0-b8a0-517da924923d'}) ,(sc9)-[:IS_PART_OF_CLUSTER]->(c) ,(sc10:Controller{serialnumber:'7000610021',system_id:'1873791030',hostname:'node10',node_uuid:'f6cf0705-6670-11e0-b8a0-517da924923d'}) ,(sc10)-[:IS_PART_OF_CLUSTER]->(c) ,(sc11:Controller{serialnumber:'7000610057',system_id:'1873784128',hostname:'node11',node_uuid:'551b1bf8-663d-11e0-b8a0-517da924923d'}) ,(sc11)-[:IS_PART_OF_CLUSTER]->(c) ,(sc12:Controller{serialnumber:'7000609981',system_id:'1873778164',hostname:'node12',node_uuid:'f6062d6c-663e-11e0-9b53-cd0ece6aa2ce'}) ,(sc12)-[:IS_PART_OF_CLUSTER]->(c) ,(sc13:Controller{serialnumber:'7000610033',system_id:'1873778186',hostname:'node13',node_uuid:'ed0e61c5-6670-11e0-b07f-933da0385fdc'}) ,(sc13)-[:IS_PART_OF_CLUSTER]->(c) ,(sc14:Controller{serialnumber:'7000610069',system_id:'1873784175',hostname:'node14',node_uuid:'8623ea28-66ae-11e0-ab9d-5fdc7f30dee7'}) ,(sc14)-[:IS_PART_OF_CLUSTER]->(c) ,(sc15:Controller{serialnumber:'7000606109',system_id:'1873778197',hostname:'node15',node_uuid:'b4349a83-6682-11e0-ab9d-5fdc7f30dee7'}) ,(sc15)-[:IS_PART_OF_CLUSTER]->(c) ,(sc16:Controller{serialnumber:'7000610045',system_id:'1873784157',hostname:'node16',node_uuid:'67d80db8-663d-11e0-9b53-cd0ece6aa2ce'}) ,(sc16)-[:IS_PART_OF_CLUSTER]->(c) ,(sc17:Controller{serialnumber:'7001246085',system_id:'2014175904',hostname:'node19',node_uuid:'1c792588-ff4e-11db-94fe-3b91dd7dd242'}) ,(sc17)-[:IS_PART_OF_CLUSTER]->(c) ,(sc18:Controller{serialnumber:'7001246097',system_id:'2014176797',hostname:'node20',node_uuid:'3ae9e7ae-ff44-11db-864d-af2af862bba3'}) ,(sc18)-[:IS_PART_OF_CLUSTER]->(c) RETURN c,sc1,sc2,sc3,sc4,sc5,sc6,sc7,sc8,sc9,sc10,sc11,sc12,sc13,sc14,sc15,sc16,sc17,sc18 19 nodes created, 18 relationships. Now when I run the first query again, it takes one minute and will eventually return with 'Unknown error'. Cypher Query: MATCH (c:Cluster{cluster_name:'mycluster',cluster_uuid:'7bd4f66d-5faf-11db-8d0d-000e0cba569c'}) ,(sc1:Controller{serialnumber:'7000610071',system_id:'1873784171',hostname:'node01',node_uuid:'7cd70205-66ae-11e0-a4a9-0deba859517d'}) ,(sc1)-[:IS_PART_OF_CLUSTER]->(c) ,(sc2:Controller{serialnumber:'7000606111',system_id:'1873778118',hostname:'node02',node_uuid:'b954f0a1-6682-11e0-b8a0-517da924923d'}) ,(sc2)-[:IS_PART_OF_CLUSTER]->(c) ,(sc3:Controller{serialnumber:'7000561878',system_id:'1873772083',hostname:'node03',node_uuid:'ac293586-6690-11e0-b8a0-517da924923d'}) ,(sc3)-[:IS_PART_OF_CLUSTER]->(c) ,(sc4:Controller{serialnumber:'800000075807',system_id:'1873784143',hostname:'node04',node_uuid:'e8d6c7e5-663e-11e0-b8a0-517da924923d'}) ,(sc4)-[:IS_PART_OF_CLUSTER]->(c) ,(sc5:Controller{serialnumber:'7000477261',system_id:'1873745662',hostname:'node05',node_uuid:'1d1ecc64-728c-11e0-bf0e-3d25383f7ed3'}) ,(sc5)-[:IS_PART_OF_CLUSTER]->(c) ,(sc6:Controller{serialnumber:'7000477273',system_id:'1873745654',hostname:'node06',node_uuid:'140fb0f9-728c-11e0-afeb-49fcf0b6e6c3'}) ,(sc6)-[:IS_PART_OF_CLUSTER]->(c) ,(sc7:Controller{serialnumber:'7000474908',system_id:'1873745665',hostname:'node07',node_uuid:'edbf9c62-728b-11e0-bf0e-3d25383f7ed3'}) ,(sc7)-[:IS_PART_OF_CLUSTER]->(c) ,(sc8:Controller{serialnumber:'7000474910',system_id:'1873745695',hostname:'node08',node_uuid:'20dbfe67-7832-11e0-afeb-49fcf0b6e6c3'}) ,(sc8)-[:IS_PART_OF_CLUSTER]->(c) ,(sc9:Controller{serialnumber:'7000609864',system_id:'1873802756',hostname:'node09',node_uuid:'a8b75397-6690-11e0-b8a0-517da924923d'}) ,(sc9)-[:IS_PART_OF_CLUSTER]->(c) ,(sc10:Controller{serialnumber:'7000610021',system_id:'1873791030',hostname:'node10',node_uuid:'f6cf0705-6670-11e0-b8a0-517da924923d'}) ,(sc10)-[:IS_PART_OF_CLUSTER]->(c) ,(sc11:Controller{serialnumber:'7000610057',system_id:'1873784128',hostname:'node11',node_uuid:'551b1bf8-663d-11e0-b8a0-517da924923d'}) ,(sc11)-[:IS_PART_OF_CLUSTER]->(c) ,(sc12:Controller{serialnumber:'7000609981',system_id:'1873778164',hostname:'node12',node_uuid:'f6062d6c-663e-11e0-9b53-cd0ece6aa2ce'}) ,(sc12)-[:IS_PART_OF_CLUSTER]->(c) ,(sc13:Controller{serialnumber:'7000610033',system_id:'1873778186',hostname:'node13',node_uuid:'ed0e61c5-6670-11e0-b07f-933da0385fdc'}) ,(sc13)-[:IS_PART_OF_CLUSTER]->(c) ,(sc14:Controller{serialnumber:'7000610069',system_id:'1873784175',hostname:'node14',node_uuid:'8623ea28-66ae-11e0-ab9d-5fdc7f30dee7'}) ,(sc14)-[:IS_PART_OF_CLUSTER]->(c) ,(sc15:Controller{serialnumber:'7000606109',system_id:'1873778197',hostname:'node15',node_uuid:'b4349a83-6682-11e0-ab9d-5fdc7f30dee7'}) ,(sc15)-[:IS_PART_OF_CLUSTER]->(c) ,(sc16:Controller{serialnumber:'7000610045',system_id:'1873784157',hostname:'node16',node_uuid:'67d80db8-663d-11e0-9b53-cd0ece6aa2ce'}) ,(sc16)-[:IS_PART_OF_CLUSTER]->(c) ,(sc17:Controller{serialnumber:'7001246085',system_id:'2014175904',hostname:'node19',node_uuid:'1c792588-ff4e-11db-94fe-3b91dd7dd242'}) ,(sc17)-[:IS_PART_OF_CLUSTER]->(c) ,(sc18:Controller{serialnumber:'7001246097',system_id:'2014176797',hostname:'node20',node_uuid:'3ae9e7ae-ff44-11db-864d-af2af862bba3'}) ,(sc18)-[:IS_PART_OF_CLUSTER]->(c) RETURN c,sc1,sc2,sc3,sc4,sc5,sc6,sc7,sc8,sc9,sc10,sc11,sc12,sc13,sc14,sc15,sc16,sc17,sc18 Returns Unknown Error
Your MATCH query is way to complicated. There's no need to specify every node. The following query returns the cluster and its related controllers: MATCH (c:Cluster{cluster_name:'mycluster',cluster_uuid:'7bd4f66d-5faf-11db-8d0d-000e0cba569c'})<-[:IS_PART_OF_CLUSTER]-(sc:Controller) WITH c, collect(sc) as controllers RETURN c as cluster, controllers
How to use START with Cypher / Neo4j 2.0
I am trying example provided in Graph Databases book (PDF page 51-52)with Neo4j 2.0.1 (latest). It appears that I cannot just copy paste the code sample from the book (I guess the syntax is no longer valid). START bob=node:user(username='Bob'), charlie=node:user(username='Charlie') MATCH (bob)-[e:EMAILED]->(charlie) RETURN e Got #=> Index `user` does not exist. So, I tried without 'user' START bob=node(username='Bob'), charlie=node(username='Charlie') MATCH (bob)-[e:EMAILED]->(charlie) RETURN e Got #=> Invalid input 'u': expected whitespace, an unsigned integer, a parameter or '*' Tried this but didn't work START bob=node({username:'Bob'}), (charlie=node({username:'Charlie'}) MATCH (bob)-[e:EMAILED]->(charlie) RETURN e Got #=> Invalid input ':': expected an identifier character, whitespace or '}' I want to use START then MATCH to achieve this. Would appreciate little bit of direction to get started.
From version 2.0 syntax has changed. http://docs.neo4j.org/chunked/stable/query-match.html Your first query should look like this. MATCH (bob {username:'Bob'})-[e:EMAILED]->(charlie {username:'Charlie'}) RETURN e
The query does not work out of the box because you'll need to create the user index first. This can't be done with Cypher though, see the documentation for more info. Your syntax is still valid, but Lucene indexes are considered legacy. Schema indexes replace them, but they are not fully mature yet (e.g. no wildcard searches, IN support, ...). You'll want to use labels as well, in your case a User label. The query can be refactored to: MATCH (b:User { username:'Bob' })-[e:EMAILED]->(c:User { username:'Charlie' }) RETURN e For good performance, add a schema index on the username property as well: CREATE INDEX ON :User(username)
Start is optional, as noted above. Given that it's listed under the "deprecated" section in the Cypher 2.0 refcard, I would try to avoid using it going forward just for safety purposes. However, the refcard does state that you can prepend your Cypher query with "CYPHER 1.9" (without the quotes) in order to make explicit use of the older syntax.
Neo4j - traversal to find specific connected component
Using neo4j 1.9.4, I'm trying to find the connected components (all reachable nodes) from a starting node where the relationship has a certain attribute ('since') and this attribute has a defined integer value, e.g. 20130101. My initial approach was using a cypher query, but I got the feeling that this query loops to infinity if there is a loop within the graph? At least if I do not restrict the path length and restricting the length is not what I want to do. So meanwhile I started using a traversal. Using neo4jphp a traversal looks like that: $traversal->setOrder(Everyman\Neo4j\Traversal::OrderBreadthFirst) ->setPruneEvaluator(Everyman\Neo4j\Traversal::PruneNone) ->setReturnFilter(Everyman\Neo4j\Traversal::ReturnAll) ->setUniqueness(Everyman\Neo4j\Traversal::UniquenessNodeGlobal); What I think I need is something like this: ->setPruneEvaluator('javascript', "position.RELATIONSHIP().getProperty('since').EQUALS(20130101)") Obviously, RELATIONSHIP and EQUALS seem to be wrong. I adopted this from the example https://github.com/jadell/neo4jphp/wiki/Traversals, where the following valid and working pruneElevater is set: ->setPruneEvaluator('javascript', "position.endNode().getProperty('name').toLowerCase().contains('t')") I'm absolutely not familiar with JavasScript, so I can't figure out how to do that. Additionally, how can I make sure the traversal does not result in an error if there is a relationship that does not have the property "since"? If I can achieve the same using a cypher query I would accept that, too. EDIT: By the way, my approach using cypher was this: START n=node({start_node}) MATCH p = n-[*]-m WHERE ALL(x IN RELATIONSHIPS(p) WHERE HAS(x.since) AND x.since = 20130101) RETURN DISTINCT m EDIT2: Trying the suggested cypher query from ulkas give me the following error: Invalid query string matching regex ``(``|[^`])*`' expected but `*' found Think we should have better error message here? Help us by sending this query to cypher#neo4j.org. Thank you, the Neo4j Team. "START n=node(40317) MATCH p = n-[r:*..]-m WHERE has(r.since) AND r.since = 20130101 RETURN DISTINCT m" ^ EDIT3: The suggestion of LameCode looked really promising, but still it returns an error: Fatal error: Uncaught exception 'Everyman\Neo4j\Exception' with message 'Unable to execute traversal [400]: Headers: Array ( [Content-Length] => 5183 [Content-Type] => application/json; charset=UTF-8 [Access-Control-Allow-Origin] => * [Server] => Jetty(6.1.25) ) Body: Array ( [message] => Failed to execute script, see nested exception. [exception] => EvaluationException [fullname] => org.neo4j.server.rest.domain.EvaluationException [stacktrace] => Array ( [0] => org.neo4j.server.scripting.javascript.JavascriptExecutor.execute(JavascriptExecutor.java:118) [1] => org.neo4j.server.rest.domain.EvaluatorFactory$ScriptedEvaluator.evalPosition(EvaluatorFactory.java:140) [2] => org.neo4j.server.rest.domain.EvaluatorFactory$ScriptedPruneEvaluator.evaluate(EvaluatorFactory.java:161) [3] => org.neo4j.graphdb.traversal.Evaluator$AsPathEvaluator.evaluate(Evaluator.java:69) [4] => org.neo4j.kernel.impl.traversal.TraverserIterator.eva in /var/www/vendor/everyman/neo4jphp/lib/Everyman/Neo4j/Command.php on line 116 And I used the following pruneEvaluator: ->setPruneEvaluator('javascript', "position.lastRelationship().hasProperty('since') && position.lastRelationship().getProperty('since') == 20130101") When changing from lastRelationship() to endNode() it at least doesn't return me an error, despite I am wondering about the many results it returns, as none of the nodes has exactly this since attribute?! So it seems even then, the prune evaluator does not get to work. I expected it to stop at each endNode if has no since property or if it is unqual the given date? What am I doing wrong, any ideas?
In regards to the Traverser that you are using. The javascript prune evaluator 'position' variable is a Path object. See: http://components.neo4j.org/neo4j/1.9.4/apidocs/org/neo4j/graphdb/Path.html Those methods should be available to you. Use lastRelationship() (because all the former relationships will have come through the prune evaluator already). The Relationship object inherits from Property Container and that has a hasProperty() method. setPruneEvaluator('javascript', "position.lastRelationship().hasProperty('since') && position.lastRelationship().getProperty('since') == 20130101") I'm not sure if you need to use the Equals method or not since it's javascript.