diff --git a/lib/query.js b/lib/query.js index be41f484..9df3b396 100644 --- a/lib/query.js +++ b/lib/query.js @@ -372,9 +372,45 @@ Query.prototype.facet = function(options){ if(options.method){ this.parameters.push('facet.method=' + options.method); } + if(options.range){ + if(options.range.field) + this.parameters.push('facet.range=' + options.range.field); + if(options.range.start !== undefined) + this.parameters.push('facet.range.start=' + options.range.start); + if(options.range.end !== undefined) + this.parameters.push('facet.range.end=' + options.range.end); + if(options.range.gap !== undefined) + this.parameters.push('facet.range.gap=' + options.range.gap); + if(options.range.hardend) + this.parameters.push('facet.range.hardend=' + options.range.hardend); + if(options.range.other) + this.parameters.push('facet.range.other=' + options.range.other); + if(options.range.include) + this.parameters.push('facet.range.include=' + options.range.include); + } return self; } +/** + * Get statistics + **/ + +Query.prototype.stats = function(options){ + var self = this; + if(options.on === false){ + this.parameters.push('stats=false'); + }else{ + this.parameters.push('stats=true'); + } + if(options.field){ + this.parameters.push('stats.field=' + options.field) + } + if(options.facet){ + this.parameters.push('stats.facet=' + options.facet) + } + return self; +} + /** * Create a MoreLikeThis. MoreLikeThis constructs a lucene query based on terms within a document. *