Indexing Array Properties

Hello Neo4j Community,

I would like clarification on how Neo4j handles indexing for array properties. Specifically, does Neo4j index the individual elements within an array, or does it treat the entire array as a single value when creating an index? Additionally, I want to confirm if the index is utilized when querying for specific elements within the array.

Examples:

Consider the following scenario:

  1. I create a Person node with an array property friendshipYears:

    CREATE (p:Person {name: "Alice", friendshipYears: [2018, 2019, 2020]});
    
  2. I then create an index on the friendshipYears property:

    CREATE INDEX FOR (p:Person) ON (p.friendshipYears);
    
  3. I run the following query to find Person nodes where 2020 is one of the friendshipYears:

    MATCH (p:Person)
    WHERE 2020 IN p.friendshipYears
    RETURN p;
    

My questions are:

  1. Does Neo4j index each element in the friendshipYears array (e.g., 2018, 2019, and 2020 as separate entries), or is the entire array [2018, 2019, 2020] indexed as a single value?

  2. When querying with WHERE 2020 IN p.friendshipYears, does Neo4j use the index, or does it perform a full scan of the Person nodes?

  3. How can I confirm that the index is being utilized in this case? Would running PROFILE on the query show an Index Seek?

Understanding this behavior is crucial for optimizing queries and deciding on the appropriate data model for cases involving arrays.

Thank you in advance for your help!