From 6f8bf842eee10aee8cc557d0c4ca3ae2c7b9025c Mon Sep 17 00:00:00 2001 From: Chirag777 Date: Thu, 5 Mar 2015 12:06:37 +0530 Subject: [PATCH] added _suggest function --- lib/elasticsearchclient/calls/core.js | 45 +++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/lib/elasticsearchclient/calls/core.js b/lib/elasticsearchclient/calls/core.js index 97ef80f..3b9fa0f 100644 --- a/lib/elasticsearchclient/calls/core.js +++ b/lib/elasticsearchclient/calls/core.js @@ -101,6 +101,51 @@ ElasticSearchClient.prototype.get = function(indexName, typeName, documentId, op return this.createCall({path:path, method:'GET'}, this.clientOptions, cb); } + +// indexName, queryObj, options +// TODO: Not a very robust piece of code - need to be refactored to be more tolerant to input +ElasticSearchClient.prototype.suggest = function(indexName, queryObj, 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; + } + + var objArgs=[] + var path='' + + // Assumes quite a lot about the input + for(var i=0;i