Spring Data Neo4j @Index annotation on collection property

85 Views Asked by At

will the SDN @Index work properly on the collection properties, something like this:

@Index(unique = false)     
private Set<Long> optionIds; 
1

There are 1 best solutions below

0
On BEST ANSWER

This is possible and should work, an index should be created on property optionIds for given label.

But most likely this will not work as you expect. The problem comes from how Neo4j indexes arrays (and the fact it can't index sets - only lists and it can't index individual elements from arrays).

Whole arrays will be indexed and then can be looked up by whole arrays again. If you want to do index lookups by whole sets use sorted sets so the ids are always in the same order in the stored array (Set is stored as array by OGM).

You can't do index lookups by individual elements from the indexed array.