ElasticSearch aggregation for recommendation engine

You have a log-centric index and you need to make an entity-centric index with a document for each user which includes that array of viewings.

This will probably involve some degree of coding on your side.
Generally the transforms API is how we'd pivot log data to an entity-centric index. This particular transformation would require some scripting of the scripted_metric aggregation to gather the video IDs into an array.

Alternatively you can write custom code to do this transformation using the search and index or update APIs.