diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/Lucene.java b/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/Lucene.java index d531593467c0b..af6d7bae055c9 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/Lucene.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/Lucene.java @@ -417,6 +417,10 @@ public static class ExistsCollector extends Collector { private boolean exists; + public void reset() { + exists = false; + } + public boolean exists() { return exists; } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/percolator/PercolatorExecutor.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/percolator/PercolatorExecutor.java index 78e63dfe23526..8afbd5936904a 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/percolator/PercolatorExecutor.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/percolator/PercolatorExecutor.java @@ -340,8 +340,9 @@ public Response percolate(DocAndQueryRequest request) throws ElasticSearchExcept List matches = new ArrayList(); if (request.query() == null) { + Lucene.ExistsCollector collector = new Lucene.ExistsCollector(); for (Map.Entry entry : queries.entrySet()) { - Lucene.ExistsCollector collector = new Lucene.ExistsCollector(); + collector.reset(); try { searcher.search(entry.getValue(), collector); } catch (IOException e) {