-
-
Save jpoth/8406466 to your computer and use it in GitHub Desktop.
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 | |
}}' |
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 '{
"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",
"bulk_size":500
}}'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 388 100 73 100 315 146 630 --:--:-- --:--:-- --:--:-- 649{"ok":true,"_index":"_river","_type":"person","_id":"_meta","_version":1}
curl -XPUT localhost:9200/_river/work/_meta -d '{
"type":"jdbc",
"jdbc": {
"sql":"s> elect person"_id as _parendt,name,genrre,publisheri from work"v,
er":"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
}}'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 401 100 71 100 330 1543 7173 --:--:-- --:--:-- --:--:-- 7173{"ok":true,"_index":"_river","_type":"work","_id":"_meta","_version":1}
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
}}'
Remove both commands "..._river/.../_mapping", run this first, then run your ".._river/.../_meta" after that