Examples


For building a demo/test data it is common to use multiple property files. This will give a good overview on what to generate. Also some constructions are only doable with multiple files.

In the examples below we build up a demo set in multiple property files which has to be loaded in the order shown below. The property files are also in the ddgres directory. So you can load these examples in your database to see the results:

	curl -g http://127.0.0.1:7474/testdata/tdg/pfile/example1.props
	
	curl -g http://127.0.0.1:7474/testdata/tdg/pfile/example2.props
	
	curl -g http://127.0.0.1:7474/testdata/tdg/pfile/example3.props
	

example 1 (example1.props)


In this sample person and city nodes are created. Also a Person likes or dislikes an other Person
# General Settings
#
# Commit Size
tdg.commit.size=2000
#
####### NODE DEFINITIONS ######
#
#  tdg.node.list contains a comma seperated list of create node definitions  [alias:label:amount]
# 
tdg.node.list=p1:Person:2000,p2:Person:800,cit:City:30
#
#    in words: 2800 nodes with label Person will be created in two 'sets'
#              20 nodes with Label City will be created
#
# Properties can be set with a label reference. This means all set's with the same Label will get these properties
# Properties can also be set with a alias reference. This means that only these properties will be set of nodes 
# for this specific alias. An alias referenced property preceeds the label referenced property
#
# Person
tdg.node.props.Person.~Person=1970-01-01,1995-01-01
tdg.node.props.Person.address=streetAddress
tdg.node.props.Person.credit=elementFrom:12,22,33,44,55.2
tdg.node.props.Person.caption=constant:Democrat
# p2
tdg.node.props.p2.caption=constant:Republican

# City
tdg.node.props.City.name=listFile:cities.txt,string
tdg.node.props.City.country=constant:USA

###### Relation Definitions ##### 
# tdg.rel.list contains a comma seperated list of relation identifiers 
tdg.rel.list=personPerson1,personPerson2,personCity1,personCity2
#
# tdg.rel.def.[rel name]=[start node identifier],relationtype,[end node identifier],cardinality
# Cardinality:
#
# 1-n      : The "end node" may have max one relation from the start node 
# n-1      : The "start node" may have max one relation to the end node
# 1-1      : The "end node" may have one relation from the start node and the 
#            "start node" may have one relation to the end node
# 
# All relations may be created if possible.
#
tdg.rel.def.personPerson1=p1,LIKES,p2,n-1
#
# we set a property on the relation here, a random percentage will be created
#
tdg.rel.props.personPerson1.weight=percentage

tdg.rel.def.personPerson2=p2,DISLIKES,p1,n-1
tdg.rel.props.personPerson2.weight=percentage

tdg.rel.def.personCity1=p1,LIVES,cit,n-1
tdg.rel.def.personCity2=p2,LIVES,cit,n-1

		

example 2 (example2.props)


In this sample Company Nodes are created and linked to the already existing City nodes which will be retrieved via the 'Lookup Nodes'.
# General Settings
#
# Commit Size
tdg.commit.size=2000
#
####### NODE DEFINITIONS ######
#
#  tdg.node.list contains a comma seperated list of create node definitions  [alias:label:amount]
# 
tdg.node.list=comp:Company:150
# Company
tdg.node.props.Company.name=companyName
tdg.node.props.Company.url=url
tdg.node.props.Company.bs=companyBS
tdg.node.props.Company.slogan=companySlogan
tdg.node.props.Company.text=txtText:40
tdg.node.props.Company.sentence=txtSentence
tdg.node.props.Company.sentences=txtSentences:3
tdg.node.props.Company.paragraph=txtParagraph:10
tdg.node.props.Company.paragraphs=txtParagraphs:3

######## Lookup nodes
# Use a cypher query to get a set of nodes to relate to.
# These lookup nodes can be used to create relations with
# any generated node and or to set propertie on them.
# note that the return set must contain nodes only
# For the cypher statements: you must use a \ to have a multiline property value
# 
tdg.lookup.nodes.list=matchCities
tdg.lookup.cypher.matchCities=match (cit:City) return cit
# we don't have to set properties on these lookup nodes

###### Relation Definitions ##### 
#tdg.rel.list contains a comma seperated list of relation identifiers 
tdg.rel.list=companyCity
#
# tdg.rel.def.[rel name]=[start node identifier],relationtype,[end node identifier],cardinality
# Cardinality:
#
# 1-n      : The "end node" may have max one relation from the start node 
# n-1      : The "start node" may have max one relation to the end node
# 1-1      : The "end node" may have one relation from the start node and the 
#            "start node" may have one relation to the end node
# 
# All relations may be created if possible.
# We have a lookup node here you must refer to lookupNode name.colname
tdg.rel.def.companyCity=comp,LOCATED_IN,matchCities.cit,n-1		

example 3 (example3.props)


In this sample persons will be related to the Companies within their City. In this example the 'repeat node' structure is used
# General Settings
#
# Commit Size
tdg.commit.size=2000
#
# Now we connect Person who are living in a city to Companies located in the same 
# city. For this we use the repeater lookup node structure
#
# first the list of repeatnodes
tdg.repeatnode.list=compperson
# note that in this query you have to return a property instead of a node!
tdg.repeatnode.input.compperson=query:match (c:City) return distinct c.name
#
# Now we have to define the repeat lookup queries
#
tdg.repeatnode.cypher.compperson.pers=MATCH (prs:Person)-[:LIVES]->(cit:City {name:'##INPUT##'}) return prs
tdg.repeatnode.cypher.compperson.comp=MATCH (cmp:Company)-[:LOCATED_IN]->(cit:City {name:'##INPUT##'}) return cmp
#
# Now we have to relate the persons with the company in the same city
#
tdg.rel.repeat.list=compprs
tdg.rel.repeat.def.compprs=compperson#pers.prs,WORKS_FOR,compperson#comp.cmp,n-1
tdg.rel.repeat.props.compprs.year=year:1950,2000
###### Relation Definitions #####
#tdg.rel.list contains a comma seperated list of relation identifiers 
# tdg.rel.list=personCompany,personPerson,hacstate
#
# tdg.rel.def.[relation identifier]=[start node identifier],relationtype,[end node identifier],cardinality
# Cardinality:
#
# 1-n      : The "end node" may have max one relation from the start node 
# n-1      : The "start node" may have max one relation to the end node
# 1-1      : The "end node" may have one relation from the start node and the "start node" may have one relation to the end node