diff --git a/src/main/java/org/elasticsearch/search/facet/terms/strings/ScriptTermsStringFieldFacetExecutor.java b/src/main/java/org/elasticsearch/search/facet/terms/strings/ScriptTermsStringFieldFacetExecutor.java index 3d06147073a..b7f5c4ece3a 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/strings/ScriptTermsStringFieldFacetExecutor.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/strings/ScriptTermsStringFieldFacetExecutor.java @@ -182,7 +182,7 @@ public class ScriptTermsStringFieldFacetExecutor extends FacetExecutor { @Override public void postCollection() { ScriptTermsStringFieldFacetExecutor.this.missing = missing; - ScriptTermsStringFieldFacetExecutor.this.total = missing; + ScriptTermsStringFieldFacetExecutor.this.total = total; } private boolean match(String value) { diff --git a/src/test/java/org/elasticsearch/test/integration/search/facet/SimpleFacetsTests.java b/src/test/java/org/elasticsearch/test/integration/search/facet/SimpleFacetsTests.java index 54c31b24063..0f9f63508bb 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/facet/SimpleFacetsTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/facet/SimpleFacetsTests.java @@ -1297,11 +1297,15 @@ public class SimpleFacetsTests extends AbstractNodesTests { facet = searchResponse.getFacets().facet("facet1"); assertThat(facet.getName(), equalTo("facet1")); + assertThat(facet.getTotalCount(), equalTo(2l)); + assertThat(facet.getOtherCount(), equalTo(0l)); assertThat(facet.getEntries().size(), equalTo(1)); assertThat(facet.getEntries().get(0).getTerm().string(), equalTo("111")); assertThat(facet.getEntries().get(0).getCount(), equalTo(2)); facet = searchResponse.getFacets().facet("facet2"); + assertThat(facet.getTotalCount(), equalTo(4l)); + assertThat(facet.getOtherCount(), equalTo(0l)); assertThat(facet.getName(), equalTo("facet2")); assertThat(facet.getEntries().size(), equalTo(3)); assertThat(facet.getEntries().get(0).getTerm().string(), equalTo("yyy"));