Hi, I have a query like this in MySQL that I am thinking to migrate to ElasticSearch for scalability:
SELELCT userID,sum(countA) as sumA,sum(countB) as sumB
FROM data_table
WHERE groupID=? AND date BETWEEN ? AND ?
GROUP BY userID
ORDER BY sumA
LIMIT ?,?
For a table of id, groupID, date, userID, countA, countB with an index of <groupID, date>.
curl -X GET "localhost:9200/_sql?format=txt&pretty=true" -H 'Content-Type: application/json' -d'
{
"query" :"SELECT email,sum(countA) FROM \"library\" GROUP BY email LIMIT 2",
"filter" :{
"range" :{
"number":{
"gte":1,
"lte":100,
}
}
}
}
'
BTW, do you know how can I get the DSL version of this query?
I am very curious how the aggregation DSL works for this because the documentation doesn't have those feature working together.
curl -X GET "localhost:9200/_sql?format=txt&pretty=true" -H 'Content-Type: application/json' -d'
{
"query" :"SELECT email,sum(countA) FROM \"library\" WHERE \"number\" between 1 and 100 GROUP BY email LIMIT 2"
}
'
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.