Skip to content

Commit

Permalink
Update solr
Browse files Browse the repository at this point in the history
- Change client.terms to client.temrsSearch
  • Loading branch information
godong9 committed Feb 29, 2016
1 parent 3d04977 commit 60a1260
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
19 changes: 19 additions & 0 deletions lib/solr.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ function Client(options){
this.ADMIN_PING_HANDLER = 'admin/ping';
this.REAL_TIME_GET_HANDLER = 'get';
this.SPELL_HANDLER = 'spell';
this.TERMS_HANDLER = 'terms';
}

/**
Expand Down Expand Up @@ -563,6 +564,24 @@ Client.prototype.spell = function(query,callback){
return this.get(this.SPELL_HANDLER, query, callback);
}

/**
* Terms search
*
* Provides access to the indexed terms in a field and the number of documents that match each term.
*
* @param {Query|Object|String} query
* @param {Function} callback(err,obj) - a function executed when the Solr server responds or an error occurs
* @param {Error} callback().err
* @param {Object} callback().obj - JSON response sent by the Solr server deserialized
*
* @return {http.ClientRequest}
* @api public
*/

Client.prototype.termsSearch = function(query,callback){
return this.get(this.TERMS_HANDLER, query, callback);
}

/**
* Send an arbitrary HTTP GET request to Solr on the specified `handler` (as Solr like to call it i.e path)
*
Expand Down
4 changes: 2 additions & 2 deletions test/terms-query-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var basePath = [config.client.path, config.client.core].join('/').replace(/\/$/,

describe('Client#createQuery',function(){
describe('#terms(options), callback)',function(){
it('should create a Terms query',function(done){
it('should create a Terms query and termsSearch',function(done){
var options = {
"on": true
, "fl": 'title'
Expand All @@ -33,7 +33,7 @@ describe('Client#createQuery',function(){
.terms(options)
.debugQuery();

client.search(query, function(err, data){
client.termsSearch(query, function(err, data){
sassert.ok(err,data);
assert.isObject(data.terms);
done();
Expand Down

0 comments on commit 60a1260

Please sign in to comment.