Restricting data based on user

I’m looking for the best way to restrict search data based on the user’s access. Now this is a bit trickier then say this method User-Restricted Access to Data | How to | Security | Guide | Algolia Documentation (or is it?)

Here’s the use case:

User has access to a course, each course has chapters and each chapter has multiple sections

  • Course
    • Chapter 1
      • Section 1
      • Section 2
      • Section 3
      • etc

Now the user cannot jump right to Chapter 1, Section 3 until they have read sections 1 & 2 first, sequentially.

I need to be able to allow the user to search the course but only the chapters and it’s sections they have previously read (which we keep track of already). I have to keep in mind, there soon will be multiple courses (with their own chapters and sections) to search through also.

Is there a better way to do this or any suggested method to implement restricting and indexing the content?