diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/FacetPhase.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/FacetPhase.java index c8d41e73d15..64c5b7faeb5 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/FacetPhase.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/FacetPhase.java @@ -59,7 +59,7 @@ public class FacetPhase implements SearchPhase { } @Override public void execute(SearchContext context) throws ElasticSearchException { - if (context.facets() == null) { + if (context.facets() == null || context.facets().facetCollectors() == null) { return; } if (context.queryResult().facets() != null) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/internal/ContextIndexSearcher.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/internal/ContextIndexSearcher.java index 92c68b78549..d846de8219d 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/internal/ContextIndexSearcher.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/internal/ContextIndexSearcher.java @@ -78,6 +78,9 @@ public class ContextIndexSearcher extends ExtendedIndexSearcher { } public List removeCollectors(String scope) { + if (scopeCollectors == null) { + return null; + } return scopeCollectors.remove(scope); }