-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX: Dry Client#spell, Client#search, Client#ping, Client#realTimeGet.
- Loading branch information
Showing
1 changed file
with
14 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
/*! | ||
* solr client | ||
* Copyright(c) 2011-2012 HipSnip Limited | ||
* Copyright(c) 2013-2014 Rémy Loubradou | ||
* Author Rémy Loubradou <remyloubradou@gmail.com> | ||
* MIT Licensed | ||
*/ | ||
|
@@ -76,6 +77,7 @@ function Client(options){ | |
this.SELECT_HANDLER = 'select'; | ||
this.ADMIN_PING_HANDLER = 'admin/ping'; | ||
this.GET_HANDLER = 'get'; | ||
this.SPELL_HANDLER = 'spell'; | ||
} | ||
|
||
/** | ||
|
@@ -151,15 +153,10 @@ Client.prototype.realTimeGet = function(ids, options, callback){ | |
options = {}; | ||
} | ||
ids = Array.isArray(ids) ? ids : [ids]; | ||
options.ids=ids.join(','); | ||
options.ids = ids.join(','); | ||
|
||
var qs = querystring.stringify(options); | ||
this.options.fullPath = [this.options.path,this.options.core, this.GET_HANDLER + '?' + qs ] | ||
.filter(function(element){ | ||
return element; | ||
}) | ||
.join('/'); | ||
return queryRequest(this.options,callback); | ||
var query = querystring.stringify(options); | ||
return this.get(this.GET_HANDLER,query,callback); | ||
} | ||
|
||
/** | ||
|
@@ -188,14 +185,10 @@ Client.prototype.addRemoteResource = function(options,callback){ | |
}else{ | ||
options.parameters['stream.file'] = options.path; | ||
} | ||
var path = this.UPDATE_HANDLER + '/' + options.format.toLowerCase() + '?' + querystring.stringify(options.parameters) + '&wt=json'; | ||
this.options.fullPath = [this.options.path, this.options.core, path] | ||
.filter(function(element){ | ||
if(element) return true; | ||
return false; | ||
}) | ||
.join('/'); | ||
return queryRequest(this.options,callback); | ||
|
||
var handler = this.UPDATE_HANDLER + '/' + options.format.toLowerCase(); | ||
var query = querystring.stringify(options.parameters); | ||
return this.get(handler,query,callback); | ||
} | ||
|
||
/** | ||
|
@@ -492,14 +485,7 @@ Client.prototype.update = function(data,options,callback){ | |
*/ | ||
|
||
Client.prototype.search = function(query,callback){ | ||
// Allow to be more flexible allow query to be a string and not only a Query object | ||
var parameters = query.build ? query.build() : query; | ||
this.options.fullPath = [this.options.path,this.options.core, this.SELECT_HANDLER + '?' + parameters + '&wt=json'] | ||
.filter(function(element){ | ||
return element; | ||
}) | ||
.join('/'); ; | ||
return queryRequest(this.options,callback); | ||
return this.get(this.SELECT_HANDLER, query, callback); | ||
} | ||
|
||
/** | ||
|
@@ -533,14 +519,7 @@ Client.prototype.searchAll = function(callback){ | |
*/ | ||
|
||
Client.prototype.spell = function(query,callback){ | ||
// Allow to be more flexible allow query to be a string and not only a Query object | ||
var parameters = query.build ? query.build() : query; | ||
this.options.fullPath = [this.options.path,this.options.core,'spell?' + parameters + '&wt=json'] | ||
.filter(function(element){ | ||
return element; | ||
}) | ||
.join('/'); ; | ||
return queryRequest(this.options,callback); | ||
return this.get(this.SPELL_HANDLER, query, callback); | ||
} | ||
|
||
/** | ||
|
@@ -556,7 +535,7 @@ Client.prototype.spell = function(query,callback){ | |
* @api public | ||
*/ | ||
|
||
Client.prototype.get = function(path,query,callback){ | ||
Client.prototype.get = function(handler,query,callback){ | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
marc-portier
Collaborator
|
||
if(typeof(query) === 'function'){ | ||
callback = query; | ||
var parameters = ''; | ||
|
@@ -565,7 +544,7 @@ Client.prototype.get = function(path,query,callback){ | |
var parameters = query.build ? query.build() : query; | ||
} | ||
|
||
this.options.fullPath = [this.options.path,this.options.core,path + '?' + parameters + '&wt=json'] | ||
this.options.fullPath = [this.options.path,this.options.core,handler + '?' + parameters + '&wt=json'] | ||
.filter(function(element){ | ||
return element; | ||
}) | ||
|
@@ -603,12 +582,7 @@ Client.prototype.escapeSpecialChars = format.escapeSpecialChars; | |
*/ | ||
|
||
Client.prototype.ping = function(callback){ | ||
this.options.fullPath = [this.options.path,this.options.core, this.ADMIN_PING_HANDLER + '?wt=json'] | ||
.filter(function(element){ | ||
return element; | ||
}) | ||
.join('/'); | ||
return queryRequest(this.options,callback); | ||
return this.get(this.ADMIN_PING_HANDLER, callback); | ||
} | ||
|
||
/** | ||
|
@lbdremy
this claimes the get() name for this generic handler instead of using handleGet()
Thus making get() unavailable for my usage in fixing #88 - supporting realtime get mapping onto the /get solr-request-handler.
See also this recent discussions:
I had all this ready up in these branches by the way:
(was just waiting for #91 to present nice new diffs to that)
Please advise on how you would want to proceed (i.e. which names to choose for generic handleGet and handelPost - versus realtimeget) so I can adjust my patches.