-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Upserts to ElasticSearch #52
base: master
Are you sure you want to change the base?
Conversation
Care to add test cases? |
sure, I can do that, I'll put some in :) |
By the way does ElasticSearch provides an api called |
yes, I think it's a relatively new feature, if you look at the guide, it's Here are some other discussions on it: regards, Bob Axford On Sat, Feb 16, 2013 at 8:07 AM, Juzer Ali [email protected] wrote:
|
ps will look at test cases early next week regards, Bob Axford On Sat, Feb 16, 2013 at 9:24 AM, Bob Axford [email protected] wrote:
|
Hi, I've added test cases for the upsert functionality, please let me know how this looks and if you'd like anything else. cheers |
Hi, I had a problem that update did fail always "Error missing doc" on ES 0.90.5. So I improved the function and included "upsert". To avoid trouble with old version with npm install I defined the prototype function in my program code. But it would be nice to get it merged here. var ElasticSearchClient = require('elasticsearchclient'); ElasticSearchClient.prototype.update = function(indexName, typeName, documentId, document, options, cb) { //Pull the callback and set it false to not clobber id. if(typeof arguments[arguments.length-1]=='function'){ cb=arguments[arguments.length-1]; arguments[arguments.length-1]=false; } document = document || {}; document = {"doc": document, "doc_as_upsert":true} var path = '/' + indexName + '/' + typeName + '/'+documentId+'/_update'; var qs = ''; if (options) { qs = querystring.stringify(options) } if (qs.length > 0) { path += "?" + qs; } return this.createCall({data: JSON.stringify(document), path: path, method: 'POST'}, this.clientOptions, cb); } |
I've added a function to core.js to allow upserts into elastic search.
I'm not sure if this is the best way to do it, but I've added parameters for script, params and the document separately.
Hope this is helpful, any comments on it would be welcomed :)