cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Use index on LABEL (not properties)

Hi all!

I have a database with 34 labels and i'm using that labels to add properties based on groups.

i.e:

MATCH (x:FST) set x:GRPONE;
MATCH (x:SND) set x:GRPONE;
...
MATCH (x:TRD) set x:GRPTWO;
...
MATCH (x:FRD) set x:GRPTHREE;
...

MATCH (x:GRPONE)-[*]->(:GROUPTWO)<--(:GRPTHREE) SET x.importantPropertie=1;

(the match to set properties sometimes involves counting other properties, relation properties, and more)

Is there any way to create index based on labels (and not properties) to prevent NodeByLabel on matches?

I'm trying another version of my script using a property instead of labels but I can't create (and remove) an index on ALL labels. Is that possible?

Thanks in advance
Regards Juan Pablo

2 REPLIES 2

I'm not entirely clear on what you're asking.

Indexes are based on label + property, you need both.

And if you want to look up a node by its label and you don't have a property to use for lookup, then it will do a NodeByLabelScan, looking at all nodes for the given label, there's literally no better option, it's literally an index based on labels as you requested.

That's exactly what I was asking.

Thanks for the answer and sorry about my English.