Elasticsearch query: multiple fields group by


(김혜숙) #1

Hi,

I want to convert the following query in mysql to elastic search:

Select field1, count(field1), field2, count(field2), field3, count(field3)
from table1
group by field1, field2, field3
Having ddate between ‘2017202’ and ‘20180101’

Thanks,


(David Pilato) #2

You can use:

Having ddate between ‘2017202’ and ‘20180101’

A range query: https://www.elastic.co/guide/en/elasticsearch/reference/6.1/query-dsl-range-query.html

group by field1, field2, field3

Terms aggregations: https://www.elastic.co/guide/en/elasticsearch/reference/6.1/search-aggregations-bucket-terms-aggregation.html


(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.