Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-31-2019 03:32 PM
Is it possible to create an index on objects inside list properties of Neo4j?
Lets say I have a bunch of Nodes
unwind range(1,100) as num CREATE (n:Person {current_id:num,old_id:[]});
call apoc.coll.zipToRows(range(1,100),range(200,300)) yield value with value[0] as old_id,value[1] as new_id Match (p:Person) where p.current_id = old_id SET p.old_id = p.old_id + old_id, p.current_id = new_id;
call apoc.coll.zipToRows(range(200,300),range(400,500)) yield value with value[0] as old_id,value[1] as new_id Match (p:Person) where p.current_id = old_id SET p.old_id = p.old_id + old_id, p.current_id = new_id;
call apoc.coll.zipToRows(range(400,500),range(600,700)) yield value with value[0] as old_id,value[1] as new_id Match (p:Person) where p.current_id = old_id SET p.old_id = p.old_id + old_id, p.current_id = new_id;
Is it possible to index the values inside old_id such that if I want to find Person's with old_id 5 the objects in old_ids are indexed?
05-31-2019 04:03 PM
This isn't supported at this time.
For lookup capability here we'd recommend modeling this as connected nodes instead, querying to them and traversing to the connected node.
Something like this for refactoring, though of course other considerations could alter your model (you can add your index on :OldId(id) before this, to improve the MERGE efficiency):
MATCH (p:Person)
UNWIND p.old_id as oldId
MERGE (old:OldId {id:oldId})
MERGE (p)-[:HAD_ID]->(old)
All the sessions of the conference are now available online