def test_facet_terms(self):
        FacetTest.index_data([
                {'id': 1, 'color': 'red'},
                {'id': 2, 'color': 'red'},
                {'id': 3, 'color': 'red'},
                {'id': 4, 'color': 'yellow'},
                {'id': 5, 'color': 'yellow'},
                {'id': 6, 'color': 'green'},
                {'id': 7, 'color': 'blue'},
                {'id': 8, 'color': 'white'},
                {'id': 9, 'color': 'brown'},
            ])
        FacetTest.refresh()

        qs = (self.get_s()
              .facet_raw(created1={
                    'terms': {
                        'field': 'color',
                        'size': 2
                    }
              })
        )

        data = qs.facet_counts()
        eq_(data["created1"].data,
            [
                {u'count': 3, u'term': u'red'},
                {u'count': 2, u'term': u'yellow'}
            ]
        )
Test terms facet
dataset/ETHPy150Open mozilla/elasticutils/elasticutils/tests/test_query.py/FacetTest.test_facet_terms