diff --git a/src/main/java/org/elasticsearch/percolator/PercolatorService.java b/src/main/java/org/elasticsearch/percolator/PercolatorService.java index eeabdc7aece..d00a1b280ab 100644 --- a/src/main/java/org/elasticsearch/percolator/PercolatorService.java +++ b/src/main/java/org/elasticsearch/percolator/PercolatorService.java @@ -100,9 +100,7 @@ public class PercolatorService extends AbstractComponent { } if (collector.exists()) { - if (!context.limit) { - matches.add(entry.getKey()); - } else if (count < context.size) { + if (!context.limit || count < context.size) { matches.add(entry.getKey()); } count++; diff --git a/src/main/java/org/elasticsearch/percolator/QueryCollector.java b/src/main/java/org/elasticsearch/percolator/QueryCollector.java index 034d72606ab..f983e846433 100644 --- a/src/main/java/org/elasticsearch/percolator/QueryCollector.java +++ b/src/main/java/org/elasticsearch/percolator/QueryCollector.java @@ -99,9 +99,7 @@ abstract class QueryCollector extends Collector { collector.reset(); searcher.search(query, collector); if (collector.exists()) { - if (!limit) { - matches.add(id); - } else if (counter < size) { + if (!limit || counter < size) { matches.add(id); } counter++;