How I can do a multiple TermStats? and with string as value_field?

Hi,

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 :

table

field_id
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
number'

Thanks

--
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 elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Not sure on how you can compute min, max, mean values on Strings.
I don't get it. What are you trying to do?

Could you illustrate your use case with a Gist with actual JSon documents?

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 16 sept. 2013 à 15:41, Fabien Guiraud fabien1909@gmail.com a écrit :

Hi,

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 :

table

field_id
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 number'

Thanks

--
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 elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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 elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Yes of course!

Here is the Gist : https://gist.github.com/zywx/6581246

In fact, I have 2 problems :

  1. I would like to get all channel_id and for each one the sum of
    views_count, dislikes_count, likes_count, comments_count. I succeed for 1
    with terms stats but I can't do that for each one... Here is the gist of my
    query : https://gist.github.com/zywx/6581303

  2. I would like to get all brand_id and for each one the sum of
    views_count, dislikes_count, likes_count, comments_count and the distinct
    count of channel_id.
    I tried this : https://gist.github.com/zywx/6581373 but the problem is I
    don't have separate sum, and I can't have the distinct count of
    channel_id...

Any idea to help me to move forward ?

Thanks a lot

Fabien

On Monday, September 16, 2013 3:56:49 PM UTC+2, David Pilato wrote:

Not sure on how you can compute min, max, mean values on Strings.
I don't get it. What are you trying to do?

Could you illustrate your use case with a Gist with actual JSon documents?

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet https://twitter.com/dadoonet | @elasticsearchfrhttps://twitter.com/elasticsearchfr
| @scrutmydocs https://twitter.com/scrutmydocs

Le 16 sept. 2013 à 15:41, Fabien Guiraud <fabie...@gmail.com <javascript:>>
a écrit :

Hi,

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 :

table

field_id
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
number'

Thanks

--
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 elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
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 elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.