Group by with count distinct on a string field

(Fabien Guiraud) #1


I have a big problem with ES : I want to do a group by and I want to count
distinct on a value (string value)

I tried with TermStats but it seems it doesn't support string as value...

any idea?

If it can help, my model :


field_a (string)
field_b (array of ids)
field_c (count)

In a SQL way, I want : "SELECT sum(field_c), COUNT(DISTINCT(field_a)) FROM
table GROUP BY field_b

I have no problem with SUM(field_c) with TermStats, but impossible to do
the same thing with a string value, I have an error : 'field_a is not a


You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
For more options, visit

(system) #2