cardinality - The number of unique elements in an array
Returns the number of unique elements in the array
Syntax
Arguments
Name | Type | Required | Description |
---|---|---|---|
array | array of type T | true | T must be either string , bool , number , interval , timestamp , regexp or enum |
Example - Detecting new IP addresses
Consider the following document:
Assume that we have a closed system, and we know that we should only have, at most, five users. Any more is cause for concern. We can use cardinality
to count the number of unique IP addresses in our array.
This will result in the following document:
This can now power alerts, reports and more.
Theme
Light