Hi @vsr1
I am sytrugling with a query, and I was hopeing you could help me:
I have these documents:
document with key: app-rank_top-free_us_1619618400
{
"chart_apps": {
"293778748": 148,
"329218549": 181,
"346453382": 485
},
"country_code": "us",
"chart_timestamp": 1619618400,
"type": "app-rank",
"version": 1
}
Document with key:
app:a2t:293778748 (the number is the key from the chart_apps object above)
{
"app_id": 293778748",
"app_uuid": "070899ba-5e93-4905-bc1d-375d636f7eff",
"sub_type": "a2t",
"key": "app:a2t:293778748",
"created_timestamp": 1602806431,
"type": "app-mapping",
"version": 2
}
Document with key:
meta:070899ba-5e93-4905-bc1d-375d636f7eff:us // meta:app_uuid:country_code
{
"app_uuid": "070899ba-5e93-4905-bc1d-375d636f7eff",
"sub_type": "app",
"user_rating_avg": 4.15874,
"user_rating_count": 18004
"created_timestamp": 1602806763,
"type": "app-tracker",
"version": 2,
"updated_timestamp": 1619495915
}
I have this query:
SELECT RAW OBJECT v3.app_uuid:d.chart_apps.[TO_STR(v3.app_id)] FOR v3 IN app_key END
FROM `tracker` d USE KEYS ["app-rank_top-free_us_1619618400", "app-rank_top-paid_dz_1619618400", "app-rank_top-free_ao_1619618400", "app-rank_top-free_ai_1619618400"]
LET app_key = (
SELECT d2.app_uuid AS app_uuid,
d2.app_id AS app_id
FROM `app-live` AS d2 USE KEYS ARRAY "app:a2t:" || v FOR v IN OBJECT_NAMES(d.chart_apps) END)
and I am getting these results:
[
{
"070899ba-5e93-4905-bc1d-375d636f7eff": 298,
"012496e0-1be7-4158-a220-acc1c0a14dbb": 272
},
{
"001dfa94-c107-42b6-bfac-83266e567eaa": 211,
"00a802da-390e-46e6-951d-d4d93489a2a2": 61
}
]
Now, what I am trying to achieve is a long list (approx 50k appuids in groups of approx 500) similar to this one:
[
{
"070899ba-5e93-4905-bc1d-375d636f7eff":{
"rank":148,
"user_rating_avg":4.15874,
"user_rating_count":18004
},
"001c4696-75cd-40c8-a9d1-f604f612dd23":{
"rank":181,
"user_rating_avg":2.3543,
"user_rating_count":234234
},
"f604f612dd23d-a9d1-bc1d--375d636f7eff":{
"rank":485,
"user_rating_avg":4.254,
"user_rating_count":6545656
}
},
{
"9b136f66-87fa-4907-95c6-f4db4a8445b6":{
"rank":148,
"user_rating_avg":4.67,
"user_rating_count":3456
},
"ce42ca64-15da-479d-9666-f774c3c607b9":{
"rank":181,
"user_rating_avg":3.654,
"user_rating_count":654
},
"010f764a-128c-4cd8-b2f3-2439bd9d5495":{
"rank":485,
"user_rating_avg":1.654,
"user_rating_count":87
}
}
]
I don’t know how to create an object inside another object …
I would appreciate any help
Thank you,