Closed ComLock closed 5 years ago
@sigdestad This would make for safer code and less configuration in the project I'm working on.
@runarmyklebust can this be done? is it ES that does the aggregation? can it be altered to return key type?
https://xp.readthedocs.io/en/stable/developer/search/aggregations/terms.html
No, we dont know anything about whats returned in the aggregations, this must be handled by the one that creates the query.
Workaround for this is to look at the value and guess what type it is.
So which version of UUID are we using?
https://stackoverflow.com/questions/136505/searching-for-uuids-in-text-with-regex
UUID v1 :
/^[0-9A-F]{8}-[0-9A-F]{4}-[1][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i UUID v2 :
/^[0-9A-F]{8}-[0-9A-F]{4}-[2][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i UUID v3 :
/^[0-9A-F]{8}-[0-9A-F]{4}-[3][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i UUID v4 :
/^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i UUID v5 :
/^[0-9A-F]{8}-[0-9A-F]{4}-[5][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i
Looking at a content id, I can see we are using UUID4
When you aggregate on a terms, the returned bucket keys might be of different types.
Typically its either a useful string, or it's a contentId, it could even by a node.id (see https://github.com/enonic/xp/issues/6757).
However it could be any combination of them, so it would be nice if there was a type field so that I could handle the various results differently.