Skip to content

Instantly share code, notes, and snippets.

@jpoth jpoth/gist:8406466
Last active Jan 3, 2016

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

dqduc commented Jan 14, 2014

Remove both commands "..._river/.../_mapping", run this first, then run your ".._river/.../_meta" after that

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"}
        }
      }
    }
}' 
@jpoth

This comment has been minimized.

Copy link
Owner Author

jpoth commented Jan 14, 2014

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}

@dqduc

This comment has been minimized.

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
You can’t perform that action at this time.