Setup parent/child using rivers


(jsp) #1

I am reading data from Sql Server database/table using jdbc-river
currently. As of now I have created a type for each table in my database.
As next step in my implementation I would like to use parent/child types so
that I can translate the relationship between my sql tables and store them.

Table1
Col_id| name| prop1|prop2|prop3

child_table1
col_id| table_id| child_prop1|child_prop2|child_prop3

curl -XPUT 'localhost:9200/_river/parent/_meta' -d '{
"type" : "jdbc",
"jdbc" : {
"driver" : "com.mysql.jdbc.Driver",
"url" : "jdbc:mysql://localhost:3306/test",
"user" : "",
"password" : "",
"sql" : "select * from table1",
"index" : "index1",
"type" : "parent"
}
}'

curl -XPUT 'localhost:9200/_river/child/_meta' -d '{
"type" : "jdbc",
"jdbc" : {
"driver" : "com.mysql.jdbc.Driver",
"url" : "jdbc:mysql://localhost:3306/test",
"user" : "",
"password" : "",
"sql" : "select * from child_table1",
"index" : "index1",
"type" : "child"
}
}'

curl -XPOST 'localhost:9200/_river/child/_mapping' -d '{
"child":{
"_parent": {"type": "parent"}
}
}'

I would like to store my data in the following format

{
"id": "1",
"name": "name1",
"prop1": "data",
"prop2": "data",
"prop3": "data",

"child": [
{
"child_prop1": "data",
"child_prop2": "data",
"child_prop3": "data",
}
{
"child_prop1": "data1",
"child_prop2": "data1",
"child_prop3": "data1",
}
]}

Can anyone comment on how can I use jdbc-rivers to store my data as
parent/child type for above scenario.

thanks

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/de9ede70-45f2-45d5-bdfb-143d95852262%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Maarten Roosendaal) #2

Hi,

What you can do is include the 'parent' in the sql and give it the value of
the parentId. I think you have to do this in 2 runs, first all the parents,
second all the children.

see
http://elasticsearch-users.115913.n3.nabble.com/JDBC-River-amp-amp-parent-td4029976.html for
another discussion

Good luck,
Maarten

Op donderdag 9 januari 2014 22:04:09 UTC+1 schreef jsp:

I am reading data from Sql Server database/table using jdbc-river
currently. As of now I have created a type for each table in my database.
As next step in my implementation I would like to use parent/child types so
that I can translate the relationship between my sql tables and store them.

Table1
Col_id| name| prop1|prop2|prop3

child_table1
col_id| table_id| child_prop1|child_prop2|child_prop3

curl -XPUT 'localhost:9200/_river/parent/_meta' -d '{
"type" : "jdbc",
"jdbc" : {
"driver" : "com.mysql.jdbc.Driver",
"url" : "jdbc:mysql://localhost:3306/test",
"user" : "",
"password" : "",
"sql" : "select * from table1",
"index" : "index1",
"type" : "parent"
}
}'

curl -XPUT 'localhost:9200/_river/child/_meta' -d '{
"type" : "jdbc",
"jdbc" : {
"driver" : "com.mysql.jdbc.Driver",
"url" : "jdbc:mysql://localhost:3306/test",
"user" : "",
"password" : "",
"sql" : "select * from child_table1",
"index" : "index1",
"type" : "child"
}
}'

curl -XPOST 'localhost:9200/_river/child/_mapping' -d '{
"child":{
"_parent": {"type": "parent"}
}
}'

I would like to store my data in the following format

{
"id": "1",
"name": "name1",
"prop1": "data",
"prop2": "data",
"prop3": "data",

"child": [
{
"child_prop1": "data",
"child_prop2": "data",
"child_prop3": "data",
}
{
"child_prop1": "data1",
"child_prop2": "data1",
"child_prop3": "data1",
}
]}

Can anyone comment on how can I use jdbc-rivers to store my data as
parent/child type for above scenario.

thanks

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/8269dd11-dd60-4c09-918e-055786f0807a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #3