Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions lib/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,26 @@ Query.prototype.matchFilter = function(field,value){
return self;
}

/**
* Filter the set of documents found before to return the result with the given expression.
*
* @param {String} expression - expression
*
* @return {Query}
* @api public
*
* @example
* var query = client.createQuery();
* query.q({ '*' : '*' }).matchFilter('id', 100)
*/

Query.prototype.expressionFilter = function(expression){
var self = this;
var parameter = 'fq=' + encodeURIComponent(expression);
this.parameters.push(parameter);
return self;
}

/**
* Specify a set of fields to return.
*
Expand Down Expand Up @@ -693,6 +713,38 @@ Query.prototype.boost = function(functions){
return self;
}

/**
* Create a geo-spatial query.
*
* @param {Object} options - set of options to create a spatial
* @param {Boolean} [options.on=true] - Turn on or off spatial
* @param {String} [options.pt] - The geo position point.
* @param {String} [options.sfield] - The name of the field where the confition is applied.
* @param {Number} [options.d] - The distance in kilometers.
*
* @return {Query}
* @api public
*/

Query.prototype.spatial = function(options) {
var self = this;
if(options.on === false){
this.parameters.push('spatial=false');
}else{
this.parameters.push('spatial=true');
}
if(options.pt !== undefined) {
this.parameters.push('pt=' + encodeURIComponent(options.pt))
}
if(options.sfield !== undefined){
this.parameters.push('sfield=' + options.sfield)
}
if(options.d !== undefined){
this.parameters.push('d=' + options.d)
}
return self;
}

/**
* Build a querystring with the array of `this.parameters`.
*
Expand Down