Reducing relevance for viewed videos

Hello there!

We have a social network app that contains user's videos. The video URL is stored in a timeline index on Elastic.
When the users opens the app, we will retrieve relevant videos for him based on the video popularity, publish time, and affinity of the user with the topic that the video is about.

The problem is, when a user view a video, we want to reduce the score of this video for next queries for this user. We want to do this so that the user does not sees the same video everytime he opens the app.
How to do this in a performant way? I'm thinking on storing all users ids on a long keyword field (e.g. viewedBy), and use a "contains" method to check if this long keyword contains the user id.

Something like

"doc['likes'].value.contains('{{userId}}')"

The problem is when I have thousands of views, to update this long keyword field will be very costly for my api (it will need to retrieve all user ids and insert it as a long string).

The other solution would be by using a flattened field. With this, I would update a new view just passing the new userId to the flattened field, just as pushing a new item to an array.

Am I wrong? Is there a better approach for this problem?

Hi Gustavo.
There’s a script and some benchmarks here that should be of interest: Faster support for large exclusion lists in searches · Issue #74954 · elastic/elasticsearch · GitHub

The answer to your problem is one of those “it depends” scenarios and it will probably be a matter of picking the least worst strategy given the specifics of your data.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.