-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide "aggregation" functions in Ditto search #1525
Comments
Hi @thjaeckle, So if there is an easy way to use aggregation capabilities of the MongoDB this would be beneficial.
|
@thfries very interesting, thx for the input
You mean that eg the "groupId" would be used as "group by" in an aggregation? From your comment I assume that you would need a "distinct count" aggregation? For other queries and interpreting the sparse RQL documentation (and the lack of a specified count aggregation), I would assume that e.g. a "count" aggregation could look like:
With a response being e.g.: {
"items": [
{
"my-group-1": 42
},
{
"my-group-2": 7
}
],
...
} Another example to find out the mean temperature of a room with devices providing temperature readings:
With a response being e.g.: {
"items": [
{
"kitchen": 21.32
},
{
"living": 22.03
}
],
...
} |
Thanks for your examples. Sorry for not being precise here. You're right, the use case is not only about aggregation but also about grouping. The full example in SQL would be:
with a response being:
So the interesting part is to get a statistic overview of your fleet. |
I try to find a syntax which would support your query..
With a response being e.g.: {
"items": [
{
"attributes/roomId": "kitchen",
"features/connectivity/properties/state": "online",
"count()": 3
},
{
"attributes/roomId": "living",
"features/connectivity/properties/state": "offline",
"count()": 1
},
{
"attributes/roomId": "living",
"features/connectivity/properties/state": "online",
"count()": 4
}
],
...
} Thinkable would also be sorting aggregations:
Translated to MongoDB this query could be (I did not verify yet):
When I find the time, I will try those aggregation queries in MongoDB. 😉 |
Utilising the MongoDB search index, Ditto could support aggregation queries via its search API, e.g. in order to find out the mean temperature value of hundreds/thousands of selected things.
Our used RQL syntax also provides "aggregations":
..
If any adopter of Ditto already had a need for such kind of aggregations, please provide feedback and your use-cases for such a feature.
The text was updated successfully, but these errors were encountered: