Skip to content

Instantly share code, notes, and snippets.

@jpoth
Last active January 3, 2016 04:08
Show Gist options
  • Save jpoth/8406466 to your computer and use it in GitHub Desktop.
Save jpoth/8406466 to your computer and use it in GitHub Desktop.
elasticsearch -parent/child example
curl localhost:9200/_river/person/_mapping -d '{
"person":{
"properties:{
"person_id":{"type":"integer"},
"name":{"type":"string"}
}
}
}'
curl localhost:9200/_river/person/_meta -d '{
"type":"jdbc",
"jdbc": {
"driver":"com.microsoft.sqlserver.jdbc.SQLServerDriver",
"url":"jdbc:sqlserver://127.0.0.1:1433;databaseName=blogcontext",
"user":"sa","password":"password",
"sql":"select person_id as _id, name from person",
"poll":"30s"
},
"index": {
"index":"library",
"type":"person",
"bulk_size":500
}}'
curl -XPUT 'localhost:9200/_river/work/_mapping' -d '{
"work":{
"_parent":{"type": "person"},
"properties":{
"person_id":{"type" : "integer", "index" : "not_analyzed"},
"name":{"type" : "string"},
"genre":{"type" : "string"},
"publisher":{"type" : "string"}
}
}
}'
curl -XPUT localhost:9200/_river/work/_meta -d '{
"type":"jdbc",
"jdbc": {
"driver":"com.microsoft.sqlserver.jdbc.SQLServerDriver",
"url":"jdbc:sqlserver://127.0.0.1:1433;databaseName=blogcontext",
"user":"sa","password":"password",
"sql":"select person_id as _parent,name,genre,publisher from work",
"poll":"30s"
},
"index": {
"index":"library",
"type":"work",
"bulk_size":500
}}'
@dqduc
Copy link

dqduc commented Jan 16, 2014

river is wrong endpoint, it should be _river, so the command to create rivers will look like:

curl -XDELETE "http://localhost:9200/_river/" 

curl -XPUT localhost:9200/_river/person/meta -d '{

"type":"jdbc",
"jdbc": {
"driver":"com.microsoft.sqlserver.jdbc.SQLServerDriver",
"index":"library",
"url":"jdbc:sqlserver://127.0.0.1:1433;databaseName=blogcontext",
"user":"sa","password":"password",
"sql":"select person_id as _id, name from person",
"poll":"30s"
},
"index": {
"index":"library",
"type":"person",
"bulksize":500
}}'

curl -XPUT localhost:9200/_river/work/meta -d '{
"type":"jdbc",
"jdbc": {
"driver":"com.microsoft.sqlserver.jdbc.SQLServerDriver",
"index":"library",
"url":"jdbc:sqlserver://127.0.0.1:1433;databaseName=blogcontext",
"user":"sa","password":"password",
"sql":"select personid as _parent,name,genre,publisher from work",
"poll":"30s"
},
"index": {
"index":"library",
"type":"work",
"bulksize":500
}}'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment