add test for merging two stats field facet using same facet name

This commit is contained in:
kimchy 2010-10-11 00:40:37 +02:00
parent 18d8e9dcdd
commit 4f9d9c1395
1 changed files with 17 additions and 0 deletions

View File

@ -559,6 +559,23 @@ public class SimpleFacetsTests extends AbstractNodesTests {
assertThat(facet.max(), equalTo(4d)); assertThat(facet.max(), equalTo(4d));
assertThat(facet.mean(), equalTo(3d)); assertThat(facet.mean(), equalTo(3d));
assertThat(facet.sumOfSquares(), equalTo(20d)); assertThat(facet.sumOfSquares(), equalTo(20d));
// test cross field facet using the same facet name...
searchResponse = client.prepareSearch()
.setQuery(matchAllQuery())
.addFacet(statisticalFacet("stats").field("num"))
.addFacet(statisticalFacet("stats").field("multi_num"))
.execute().actionGet();
facet = searchResponse.facets().facet("stats");
assertThat(facet.name(), equalTo(facet.name()));
assertThat(facet.count(), equalTo(6l));
assertThat(facet.total(), equalTo(13d));
assertThat(facet.min(), equalTo(1d));
assertThat(facet.max(), equalTo(4d));
assertThat(facet.mean(), equalTo(13d / 6d));
assertThat(facet.sumOfSquares(), equalTo(35d));
} }
@Test public void testHistoFacets() throws Exception { @Test public void testHistoFacets() throws Exception {