Unable to retrieve data via python driver

Hi folks, just beginning my journey in neo4j .. i am planning to create a graph with relation between entities being represented by vectorized phrases ( so the relationship / edge will contain a small textual summary of the relation between the entities and also its vectorized format ) ..i am able to retrieve the parent and child nodes and its contents but having trouble retrieving contents of the relationship ..pfb the code for insertion

Blockquote
import json
from neo4j import GraphDatabase

with open('config.json', 'r' ) as fp:
js_ = json.load( fp )

URI = js_["URI"]
AUTH = ( js_['uname'] , js_['pwd'] )
fname_ = "emb_exp_op.csv"

with GraphDatabase.driver(URI, auth=AUTH) as driver:
print( driver.verify_connectivity() )

with driver.session() as session:
    qry_ = '''LOAD CSV WITH HEADERS FROM 'file:///'''+fname_+'''' AS row
    MERGE ( parent:Parent {text:row.parent_entity} ) WITH row, parent
    MERGE ( child:Child {text:row.child_entity} ) WITH row, child, parent
    MERGE( parent )-[ relation:RELATED_TO { property:row.relation } ]->( child )
    WITH row, child, parent, relation CALL db.create.setRelationshipVectorProperty( relation, 'embedding', apoc.convert.fromJsonList( row.relation_emb ) )'''
    result = session.run( qry_ )
    print( result.value() )

Blockquote

while trying to retrieve , this is the code i use

Blockquote

import json
from neo4j import GraphDatabase

with open('config.json', 'r' ) as fp:
js_ = json.load( fp )

URI = js_["URI"]
AUTH = ( js_['uname'] , js_['pwd'] )
fname_ = "emb_exp_op.csv"

with GraphDatabase.driver(URI, auth=AUTH) as driver:
print( driver.verify_connectivity() )

with driver.session() as session:
    qry_ = ''' MATCH ( relation:RELATED_TO ) RETURN relation.embedding '''
    result = session.run( qry_ )
    print( result.value() )

Blockquote

simply returns an array of None ..pfb a sample of the csv file i am using

parent_entity , child_entity, relation, relation_emb
photoelectric effect,classical electromagnetism,The experimental results disagree with classical electromagnetism which predicts that continuous light waves transfer energy to electrons which would then be emitted when they accumulate enough energy,"[-0.05979490652680397, 0.029119880869984627, -0.035598330199718475, 0.10272198915481567, -0.03214927390217781, -0.05320843681693077, .........

You can’t match on a relationship by itself it has to be in context of two nodes.

The match code you are using is looking for a node with a label of RELATED_TO. If you want to find all of these relationships, regardless of the nodes the connect, then you can use something like this.

Match ()-[r:RELATED_TO]->()
Return r.embedding as embedding 

Note: you don’t need to insert a ‘with’ clause after each match as you did in your code. You can chain multiple match statements together.

Thanks so much good sir :smiling_face:..so would it make sense to create an index on the vectors of the relationship properties ? That way I can search all of them much quicker, ala a vector database? Appreciate your help

thanks a ton again :slight_smile: