'Create single-property indexes on a loop in cypher
Is it possible to do something like this in cypher?
WITH ["John", "Jane"] AS names
FOREACH (name IN names | CREATE INDEX ON :Person(name))
If not, is there any APOC alternative to achieve the same?
Thanks!
Note:
I am using Neo4j 3.5
Solution 1:[1]
What exactly are you trying to do?
You can create John and Jane like this (see the docs on UNWIND)
WITH ['John','Jane'] AS names
UNWIND names AS name
CREATE (p:Person {name:name})
RETURN p
But when you create an index, you create an index for a property on all Nodes of that type. So to index "name" you only need (see docs on INDEX):
CREATE INDEX ON :Person(name)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | David Pond |
