Aggregation with java High Level Rest Client

Hello, How to convert this Query Sql with java High Level Rest Client

// select count(*) from Customer group by Last_Name, First_Name, City

Thank you in advance

Welcome!

select count(*) from Customer group by Last_Name, First_Name, City

Is most likely the same as

select count(*) from Customer

Is that what you want?

But anyway my advice would be first to write the elasticsearch query.
You can get it by using the translate API like:

DELETE customer
PUT customer
{
  "mappings": {
    "properties": {
      "City": { "type": "keyword" },
      "First_Name": { "type": "keyword" },
      "Last_Name": { "type": "keyword" }
    }
  }
}
POST customer/_doc
{
  "Last_Name": "foo", 
  "First_Name": "bar",
  "City": "somewhere"
}
POST _sql/translate
{
  "query": "select count(*) from customer"
}
POST _sql/translate
{
  "query": "select count(*) from customer group by Last_Name, First_Name, City"
}

Then adapt the result to the java High Level Rest Client.

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