Last active
January 3, 2016 04:08
-
-
Save jpoth/8406466 to your computer and use it in GitHub Desktop.
elasticsearch -parent/child example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
}}' |
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
curl -XPOST 'http://localhost:9200/library' -d '{
"settings" : {
"number_of_shards" : 1,
"number_of_replicas" : 0
},
"mappings" : {
"person" : {
"properties" : {
"person_id":{"type":"integer"},
"name":{"type":"string"}
}
},
"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/person/_meta -d '{
curl -XPUT localhost:9200/_river/work/_meta -d '{