I am trying to use elasticsearch's official client in nodejs to create indices for chouchDB. Will really appreciate any help.
This is how I am creating an index:
esClient.indices.create({index: "users_index",
body: {
"type" : "couchdb",
"couchdb" : {
"host" : "localhost",
"port" :"5984",
"db" :"users"
},
"index" : {
"index" : "users_index",
"type" : "users",
"bulk_size" : "100",
"bulk_timeout" : "10ms"
}
}}).then(function(x){
console.log(x);
callback(null);
},
function(err){
console.log(err);
callback(null);
});
When I search for data like this in sense (GET users_index/users_index/_search), I get this without any data: { "took": 1, "timed_out": false, "_shards": { "total": 1, "successful": 1, "failed": 0 }, "hits": { "total": 0, "max_score": null, "hits": [] } }
I'll really appreciate any help.
Before creating index, I am also trying to create an index template so that all my indices get the same mapping. I am doing it like following. I have not gone that far to verify if its correct. Please let me know if there are any errors in this.
esClient.indices.putTemplate({
name: "vw_index_template",
body:{
"template" : "*_index",
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"id_prkey_template" : {
"properties" : {
"_id" : {"type" : "string", "index": "not_analyzed"},
"prkey" : {"type" : "string", "index": "analyzed"}
}
}
}
}
}).then(function(res){
console.log(res);
callback(null);
}, function(error){
console.log(error);
callback(null);
});
Will really appreciate any help.
Many thanks.