2016-12-01 81 views
0

我想從包含該屬性的所有節點中刪除屬性。我正在使用的代碼是:Neo4j預計節點,關係或路徑,但得到一個字符串

call apoc.periodic.commit(" 
match (p:Person) 
with p limit {limit} 
delete p.county 
return count(*) 
",{limit:10000}) 

但我得到以下錯誤:Expected a Node, Relationship or Path, but got a String

有誰知道是什麼原因導致這個錯誤以及如何解決它?

+0

你使用的是哪個版本?這個查詢在3.0.6上與空數據庫上的APOC 3.0.4.2完美協同工作。 (順便說一下'p.county'可能會或可能不會是一個錯字。) –

+0

Neo4j是3.0.6,APOC是3.0.4.2。 這不是一個錯字,也嘗試刪除另一個屬性,但我得到了相同的錯誤 – Porjaz

+0

我明白了。我確實可以通過使用單個節點來重現你的錯誤:CREATE(p:Person {name:'p1',county:'c1'})' –

回答

1

按照Cypher documentation

The DELETE clause is used to delete graph elements — nodes, relationships or paths.

刪除的屬性,使用REMOVE條款:

The REMOVE clause is used to remove properties and labels from graph elements.

這給下面的查詢:

CALL apoc.periodic.commit(" 
    MATCH (p:Person) 
    WITH p LIMIT {limit} 
    REMOVE p.county 
", {limit:10000}) 

奇怪的是,使用RETURN爲m引入某種無限循環e,並且查詢不會終止,所以我刪除了RETURN子句。

相關問題