Skip to content

Commit

Permalink
fix bug with construction of multi-term terms queries with AND logic
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-jones committed Apr 5, 2015
1 parent 690e398 commit 98f03d5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions es.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,18 @@ function getFilters(params) {

function termsFilter(facet, filter_list) {
if (facet.logic === "AND") {
var filters = [];
for (var i=0; i < filter_list.length; i=i+1) {
var value = filter_list[i];
var tq = {"term" : {}};
tq["term"][facet.field] = value;
return tq
filters.push(tq);
}
return filters;
} else if (facet.logic === "OR") {
var tq = {"terms" : {}};
tq["terms"][facet.field] = filter_list;
return tq
return [tq];
}
}

Expand Down Expand Up @@ -238,7 +240,7 @@ function getFilters(params) {
var filter_list = filter_definition[field];

if (facet.type === "terms") {
filters.push(termsFilter(facet, filter_list))
filters = filters.concat(termsFilter(facet, filter_list)); // Note this is a concat not a push, unlike the others
} else if (facet.type === "range") {
filters.push(rangeFilter(facet, filter_list))
} else if (facet.type === "geo_distance") {
Expand Down

0 comments on commit 98f03d5

Please sign in to comment.