Create multiple index in one cypher statement?

According to this:

Creating multiple indexes in one cypher statement is possible. But I tried, it is still invalid syntax. Is this supported or not?

CREATE INDEX effect_name FOR (n:Effect) on (n._name)
CREATE INDEX beauty_name FOR (n:Beauty) on (n._name)

Hello @lingvisa :slight_smile:

This syntax is only working on Neo4j browser if you enable multi-statement query editor as said on the stack overflow post.

If you want to use the BOLT protocol for example, you should be able to cheat (not sure it's working right):

CREATE INDEX effect_name FOR (n:Effect) on (n._name)
UNION
CREATE INDEX beauty_name FOR (n:Beauty) on (n._name)

Regards,
Cobra

but is there anything to be gained by doing such.
Presumably creating an index on a label / property is a rare experience in that I might create said index today on :Person(name) and then the index is there for good such that I never need to recreate etc. I'm not sure I understand see the need/benefit of creating N indexes in one statement/transaction. Also it should be noted that a create index will return immediately for the end user but the index is then populated in the background and this could take N seconds/minutes depending on the volume of data.

Finally, the originally referenced url neo4j - Multiple CREATE INDEX ON in one cypher query - Stack Overflow was originally authored almost 7 years ago. It may still be valid but generally the date when authored should be considered

Not too much gain, but just save a few lines of code.