From 4e291f27ea6a7394e7a4a92569aba870f4825eb3 Mon Sep 17 00:00:00 2001 From: Ryan Lynch Date: Mon, 15 Apr 2013 16:29:04 -0400 Subject: [PATCH 1/4] NEW: Added support for facet range queries --- lib/query.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/query.js b/lib/query.js index be41f484..441eab1b 100644 --- a/lib/query.js +++ b/lib/query.js @@ -372,6 +372,22 @@ 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) + this.parameters.push('facet.range.start=' + options.range.start); + if(options.range.end) + this.parameters.push('facet.range.end=' + options.range.end); + if(options.range.gap) + 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; } From 2f4fab4d04d19a76ae91ee74fa5cbfa55bd3c9ce Mon Sep 17 00:00:00 2001 From: Ryan Lynch Date: Mon, 15 Apr 2013 17:12:21 -0400 Subject: [PATCH 2/4] FIX: Added support for zero values in facet range queries --- lib/query.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/query.js b/lib/query.js index 441eab1b..961f5529 100644 --- a/lib/query.js +++ b/lib/query.js @@ -375,11 +375,11 @@ Query.prototype.facet = function(options){ if(options.range){ if(options.range.field) this.parameters.push('facet.range=' + options.range.field); - if(options.range.start) + if(options.range.start !== undefined) this.parameters.push('facet.range.start=' + options.range.start); - if(options.range.end) + if(options.range.end !== undefined) this.parameters.push('facet.range.end=' + options.range.end); - if(options.range.gap) + 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); From dbc7aa472af80d66b60cee59d6ba96979efce1f6 Mon Sep 17 00:00:00 2001 From: Ryan Lynch Date: Tue, 30 Apr 2013 13:02:47 -0400 Subject: [PATCH 3/4] NEW: Added stats support --- lib/query.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/query.js b/lib/query.js index 961f5529..9b8f00a4 100644 --- a/lib/query.js +++ b/lib/query.js @@ -391,6 +391,26 @@ Query.prototype.facet = function(options){ 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=' + encodeURIComponent(options.prefix)) + } + return self; +} + /** * Create a MoreLikeThis. MoreLikeThis constructs a lucene query based on terms within a document. * From a0a7abf226752514982aced60c9be8fa02b0f80b Mon Sep 17 00:00:00 2001 From: Ryan Lynch Date: Sat, 4 May 2013 18:29:55 -0400 Subject: [PATCH 4/4] FIX: Fixed type in setting stats facet param. --- lib/query.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/query.js b/lib/query.js index 9b8f00a4..9df3b396 100644 --- a/lib/query.js +++ b/lib/query.js @@ -406,7 +406,7 @@ Query.prototype.stats = function(options){ this.parameters.push('stats.field=' + options.field) } if(options.facet){ - this.parameters.push('stats.facet=' + encodeURIComponent(options.prefix)) + this.parameters.push('stats.facet=' + options.facet) } return self; }