I'm using neomodel and the jexp-batch-importer(https://github.com/jexp/batch-import). My model looks like the following.
class TokenRel(StructuredRel):
weight = IntegerProperty(default = 1)
class TokenNode(StructuredNode):
identifier = StringProperty(unique_index = True, required = True)
count = IntegerProperty(default = 1)
occurence = Relationship('TokenNode', 'OCCURENCE', model = TokenRel)
I've tried to import nodes and relationships with jexp-batch-importer to use the model given above afterwards.
My node.cvs looks like this:
identifier:string:TokenNode count:int
spd 2
cdu 3
and edge.csv:
identifier:string:TokenNode identifier:string:TokenNode occurence
spd cdu OCCURENCE
spd cdu OCCURENCE
The import to Neo4j works fine with 2 Nodes and 2 relationships. But I can't access the relationships in neomodel. See below:
spdNode = port.getNode('spd') #exists
cduNode = port.getNode('cdu') #exists
if spdNode.occurence.is_connected(cduNode):
print('Yes') # yes will be printed
print(spdNode.count) # 2
print(spdNode.occurence.count()) # print: 0 expected: 2
print(cduNode.occurence.count()) # 0
Is there a way to map the relationship to occurence? And is it possible to increase the weight for a edge instead of creating two edges while importing with batch-importer?
Regards.
EDIT:
I have analysed the structure which the batch-importer creates and the one from neomodel and it seems that neomodel do something strange. Insert for both two nodes and one relation between them.
Structure from Batch-Importer
nodes, id, lablel, count, identifier
1, 1 , /, / , /
2, 2, /, 2, spd
3, 3, /, 3, cdu
source target typ id label weight neo4j-relation
2, 3, direct, 1, /, 1, occurence
And here the one from neomodel:
nodes, id, label, category, count, identifier
1, 1, /, TokenNode, /, /
2, 2, /, /, 1, spd
3, 4, /, /, 1, cdu
source, target, type, id, label, weight, neo4j-relation, __instance__
1, 2, direct, 2, /, 1, Token_Node, check
1, 3, direct, 3, /, 1, Token_Node, check
3, 2, direct, 1, /, 1, occurence, unchecked
So neomodel adds something like "category" and "instance" and have relations from node to all others. It also adds the "TokenNode" to the column "category". I think the batch-importer isn't compatible with neomodel :(
Is there a way to map the relationship to occurence? And is it possible to increase the weight for a edge instead of creating two edges while importing with batch-importer?
It is possible in theory to update properties, but actually that would not be something to be generalized. You can do that either upfront on the csv files, or afterwards with a cypher statement.
Or you write your own variant of the batch-importer using the BatchInserter-Java-API (you can start by forking and modifying the batch-import repo).
I don't know if neomodel needs anything else on the relationship, e.g.
type
properties on the nodes or relationships. You can test with cypher that the import worked.