I have json data as follows:
{
"artist": {
"aliases": {
"name": "Thaddeuz Anderson"
} ,
"data_quality": "Correct" ,
"id": 2377 ,
"name": "DJ Thadz" ,
"namevariations": {
"name": [
"D. J. Thadz" ,
"D.J. Thadz" ,
"DJ Thaz" ,
"Thadz"
]
} ,
"profile": "" ,
"realname": "Thaddeuz Anderson"
} ,
"id": "040a5506-5d4a-4beb-a27b-90f7cf3b0a69"
}
{
"artist": {
"data_quality": "Correct" ,
"id": 2273 ,
"name": "Riff HiFi" ,
"namevariations": {
"name": "Riff Hiffi"
} ,
"profile": ""
} ,
"id": "041bdd4d-f7ae-4bb0-b971-88f252281421"
}
I want to find the number of aliases for every artist.
So I am using the following command:
r.table('artists')('artist')('aliases').group('name').count()
The result I get is 1 in reduction. How do I get the total number of elements in the aliases array? Please help
Whenever you
groupsomething, you need to thenungroupit. So, for your query, you need to addungroupat the end.That being said, If all you want is get the number of aliases for every artist,
groupis not really the method for that. You're better of usingmergeto append an alias count to the document.