I'm on Neo4j 5.27 (community) and want to index the same property (say embedding) across two different node types—Movie and Person—with a single vector index. I’ve tried:
CREATE VECTOR INDEX multiLabelIndex
IF NOT EXISTS
FOR (n:Movie|Person) ON (n.text)
OPTIONS {
indexConfig: {
'vector.dimensions': 1536,
'vector.similarity_function': 'cosine'
}
};
but receive a syntax error about the FOR (n) clause.
Is it supported to specify multiple labels in one FOR clause?
the short answer is no, having multiple labels are not available for the Neo4j indexes.
There is an exception to this which is the FULLTEXT indexes, but they are the only ones that can have multiple labels for the same index.
Here is some documentation around creating vector indexes, https://neo4j.com/docs/cypher-manual/current/indexes/semantic-indexes/vector-indexes/#create-vector-index, and for the full syntax description https://neo4j.com/docs/cypher-manual/current/indexes/syntax/#create-vector-index (and to compare the fulltext one that allows more than one label: https://neo4j.com/docs/cypher-manual/current/indexes/semantic-indexes/full-text-indexes/#create-full-text-indexes and https://neo4j.com/docs/cypher-manual/current/indexes/syntax/#create-full-text-index)
/Therese