# Invalid input '.': expected an identifier character, whitespace, '|', a length specification, a property map or '\]'

**URL:** <https://community.neo4j.com/t/invalid-input-expected-an-identifier-character-whitespace-a-length-specification-a-property-map-or/29145>\
**Category:** Procedures & APOC\
**Tags:** apoc, cypher\
**Created:** [November 17, 2020, 8:07am UTC](https://community.neo4j.com/t/invalid-input-expected-an-identifier-character-whitespace-a-length-specification-a-property-map-or/29145 "2020-11-17T08:07:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![boris.bakman](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/boris.bakman/32/13174_2.png) [@boris.bakman](https://community.neo4j.com/u/boris.bakman)\
**Post date:** [November 17, 2020, 8:07am UTC](https://community.neo4j.com/t/invalid-input-expected-an-identifier-character-whitespace-a-length-specification-a-property-map-or/29145/1 "2020-11-17T08:07:18Z")

</div>

Hello,

executing below query I'm receiving an error:

**Query:**

```auto
    @Query( "call apoc.periodic.iterate("
            + "\"UNWIND $items as item return item\" , "
            + "\"MERGE (s1:s{id:item.customId}) "
            + "WITH s1 "
            + "MERGE (e1:e{id:item.customId}) "
            + "MERGE (s1)-[r:item.type]->(e1) "
            + "SET r.id=item.customId, r.name=item.name\", "
            + "{batchSize:5, parallel:true, iterateList:true,params:{items:$itemss}})")
    Result saveAll2(@Param("itemss") List<OrchestraRelationship> items);

```

**Error:**

```auto
Invalid input '.': expected an identifier character, whitespace, '|', a length specification, a property map or ']' (line 1, column 140 (offset: 139))
"UNWIND $_batch AS _batch WITH _batch.item AS item MERGE (s1:s{id:item.customId}) WITH s1 MERGE (e1:e{id:item.customId}) MERGE (s1)-[r:item.type]->(e1) SET r.id=item.customId, r.name=item.name"
                                                                                                                                            ^

```

The relation type should come from a parameter because I'm building lots of relations, i.e. dynamic relation type.  
Said that I tried to put a static relation name but received also an error:

**Query:**

```auto
    @Query( "call apoc.periodic.iterate("
            + "\"UNWIND $items as item return item\" , "
            + "\"MERGE (s1:s{id:item.customId}) "
            + "WITH s1 "
            + "MERGE (e1:e{id:item.customId}) "
            + "MERGE (s1)-[r:BORA]->(e1) "
            + "SET r.id=item.customId, r.name=item.name\", "
            + "{batchSize:5, parallel:true, iterateList:true,params:{items:$itemss}})")
    Result saveAll2(@Param("itemss") List<OrchestraRelationship> items);

```

**Error:**

```auto
                                                                                                                                            Variable `item` not defined (line 1, column 106 (offset: 105))
"UNWIND $_batch AS _batch WITH _batch.item AS item MERGE (s1:s{id:item.customId}) WITH s1 MERGE (e1:e{id:item.customId}) MERGE (s1)-[r:BORA]->(e1) SET r.id=item.customId, r.name=item.name"
                                                                                                          ^ -> {Long@9015} 1

```

Hope someone can advise regards.

Thanks,  
Boris

---

<div class="post-metadata">

**Author:** ![adam\_cowley](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/adam_cowley/32/145_2.png) [@adam\_cowley](https://community.neo4j.com/u/adam_cowley)\
**Post date:** [November 17, 2020, 10:06am UTC](https://community.neo4j.com/t/invalid-input-expected-an-identifier-character-whitespace-a-length-specification-a-property-map-or/29145/2 "2020-11-17T10:06:28Z")

</div>

You can't create a relationship with a dynamic type in plain cypher. To do this you'll have to use [apoc.merge.relationship](https://neo4j.com/labs/apoc/4.1/overview/apoc.merge/apoc.merge.relationship/) instead.

```auto
@Query( "call apoc.periodic.iterate("
            + "\"UNWIND $items as item return item\" , "
            + "\"MERGE (s1:s{id:item.customId}) "
            + "WITH s1 "
            + "MERGE (e1:e{id:item.customId}) "
            + "CALL apoc.merge.relationship(s1, item.type, {id: item.customId, name: item.name}, {}, e1) YIELD relationship AS r RETURN *\", "
            + "{batchSize:5, parallel:true, iterateList:true,params:{items:$itemss}})")

```

---

<div class="post-metadata">

**Author:** ![boris.bakman](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/boris.bakman/32/13174_2.png) [@boris.bakman](https://community.neo4j.com/u/boris.bakman)\
**Post date:** [November 17, 2020, 10:28am UTC](https://community.neo4j.com/t/invalid-input-expected-an-identifier-character-whitespace-a-length-specification-a-property-map-or/29145/3 "2020-11-17T10:28:52Z")

</div>

> [@adam\_cowley](#):
>
> ```auto
> @Query( "call apoc.periodic.iterate("
> + "\"UNWIND $items as item return item\" , "
> + "\"MERGE (s1:s{id:item.customId}) "
> + "WITH s1 "
> + "MERGE (e1:e{id:item.customId}) "
> + "CALL apoc.merge.relationship(s1, item.type, {id: item.customId, name: item.name}, {}, e1) YIELD relationship AS r RETURN *\", "
> + "{batchSize:5, parallel:true, iterateList:true,params:{items:$itemss}})")
> 
> ```

Hi @adam_cowley,  
first of all, thanks for the answer.

I modified the query to be as follows:

```auto
    @Query( "call apoc.periodic.iterate("
            + "\"UNWIND $items as item return item\" , "
            + "\"MERGE (s1:s{id:item.customId}) "
            + "WITH s1, item "
            + "MERGE (e1:e{id:item.customId}) "
            + "WITH s1, e1, item "
            + "CALL apoc.merge.relationship(s1, item.type, {id: item.customId, name: item.name}, {}, e1) YIELD relationship AS r RETURN *\", "
            + "{batchSize:5, parallel:true, iterateList:true,params:{items:$itemss}})")
    Result saveAll4(@Param("itemss") List<?> items);

```

But I'm experiencing the following error:

```auto
Unknown procedure output: `relationship` (line 1, column 258 (offset: 257))
"UNWIND $_batch AS _batch WITH _batch.item AS item MERGE (s1:s{id:item.customId}) WITH s1, item MERGE (e1:e{id:item.customId}) WITH s1, e1, item CALL apoc.merge.relationship(s1, item.type, {id: item.customId, name: item.name}, {}, e1) YIELD relationship AS r RETURN *"

```

I ran the command `CALL dbms.procedures()` and verified that `apoc.merge.relationship` exists.

 ![image](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/2X/9/938e1f75dc5925ebf60c13308eaa5de399e0b734.png)

What else can it be?

---

<div class="post-metadata">

**Author:** ![adam\_cowley](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/adam_cowley/32/145_2.png) [@adam\_cowley](https://community.neo4j.com/u/adam_cowley)\
**Post date:** [November 17, 2020, 10:32am UTC](https://community.neo4j.com/t/invalid-input-expected-an-identifier-character-whitespace-a-length-specification-a-property-map-or/29145/4 "2020-11-17T10:32:10Z")

</div>

Oh sorry, it's `YIELD rel` rather than `YIELD relationship`

---

<div class="post-metadata">

**Author:** ![boris.bakman](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/boris.bakman/32/13174_2.png) [@boris.bakman](https://community.neo4j.com/u/boris.bakman)\
**Post date:** [November 17, 2020, 12:04pm UTC](https://community.neo4j.com/t/invalid-input-expected-an-identifier-character-whitespace-a-length-specification-a-property-map-or/29145/5 "2020-11-17T12:04:46Z")

</div>

> [@boris.bakman](#):
>
> dbms.procedures()

Thanks, @adam_cowley, this actually helped.  
Maybe you can also help with this related thing:

Each time I'm executing the query

```auto
    @Query( "call apoc.periodic.iterate("
            + "\"UNWIND $items as item return item\" , "
            + "\"MERGE (s1:s{id:item.startNode.customId}) "
            + "WITH s1, item "
            + "MERGE (e1:e{id:item.endNode.customId}) "
            + "WITH s1, e1, item "
            + "CALL apoc.merge.relationship(s1, item.type, {id: item.customId, name: item.name}, {}, e1) YIELD rel AS r RETURN *\", "
            + "{batchSize:5, parallel:true, iterateList:true,params:{items:$itemss}})")
    Result saveAll4(@Param("itemss") List<?> items);

```

It creates the desired relation **but** each time new nodes ((s) and (e)) are being created.  
My flow is firstly inserted all the nodes, then create the relations according to some kind of mapping file between the nodes. If I want to write it as the simplest Cypher query (without apoc) then it'll look something like the following:

```auto
"MATCH (s),(e) " +
"WHERE s.id = '%s' AND e.id = '%s' " +
"CREATE UNIQUE (s)-[r:%s]->(e) " +
"SET r.id='%s', r.name='%s' ";

```

Therefore, I tried to modify the query to this:

```auto
    @Query( "call apoc.periodic.iterate("
            + "\"UNWIND $items as item return item\" , "
            + "\"MERGE (s1:item.startNodeType.name{id:item.startNode.customId}) "
            + "WITH s1, item "
            + "MERGE (e1:item.endNodeType.name{id:item.endNode.customId}) "
            + "WITH s1, e1, item "
            + "CALL apoc.merge.relationship(s1, item.type, {id: item.customId, name: item.name}, {}, e1) YIELD rel AS r RETURN *\", "
            + "{batchSize:5, parallel:true, iterateList:true,params:{items:$itemss}})")
    Result saveAll4(@Param("itemss") List<?> items);

```

I.e. in order to prevent creating the same nodes each time, I'm specifying their type.  
But this yield an **error** :

```auto
Invalid input '.': expected an identifier character, whitespace, NodeLabel, a property map, ')' or a relationship pattern (line 1, column 66 (offset: 65))
"UNWIND $_batch AS _batch WITH _batch.item AS item MERGE (s1:item.startNodeType.name{id:item.startNode.customId}) WITH s1, item MERGE (e1:item.endNodeType.name{id:item.endNode.customId}) WITH s1, e1, item CALL apoc.merge.relationship(s1, item.type, {id: item.customId, name: item.name}, {}, e1) YIELD rel AS r RETURN *"
                                                                  ^ -> {Long@9064} 1

```

**Note:**  
I tried to replace `MERGE` with `MATCH` but it doesn't work (even thought conceptually this what I desire it to do).

Any thoughts?

---

<div class="post-metadata">

**Author:** ![boris.bakman](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/boris.bakman/32/13174_2.png) [@boris.bakman](https://community.neo4j.com/u/boris.bakman)\
**Post date:** [November 17, 2020, 12:42pm UTC](https://community.neo4j.com/t/invalid-input-expected-an-identifier-character-whitespace-a-length-specification-a-property-map-or/29145/6 "2020-11-17T12:42:21Z")

</div>

Never-mind, I managed to modify the query so it won't create each time the nodes `(s),(e)`.  
This is the query:

```auto
    @Query( "call apoc.periodic.iterate("
            + "\"UNWIND $items as item return item\" , "
            + "\"MATCH (s) "
            + "WHERE s.id=item.startNode.customId "
            + "WITH s, item "
            + "MATCH (e) "
            + "WHERE e.id=item.endNode.customId "
            + "WITH s, e, item "
            + "CALL apoc.merge.relationship(s, item.type, {id: item.customId, name: item.name}, {}, e) YIELD rel AS r RETURN *\", "
            + "{batchSize:15, parallel:true, iterateList:true,params:{items:$itemss}})")
    Result saveAll4(@Param("itemss") List<?> items);

```
