DQL: Order of filter execution vs pagination

My Schema:

           name: string @index(term) .
           type Student {
                name
            }
           type Teacher {
                name
            }

Search Query:

{
    student(func:allofterms(name, "Lydia  Spirits"), first:10, offset: 0) @filter(type(Student)) {    				 
           uid
           name           
    }
}

Want to understand the order of execution in search query above and how it affects pagination? Is it right to left ? i.e 1. @filter(type(Student)) → 2. allofterms(name, “Lydia Spirits”) → 3. pagination(first:10, offset: 0) applied after evaluating previous two criteria(filter → allofterms)?

Will the pagination results(and total count) change if query changes like:
New Search Query:

{
    student(func:type(Student), first:10, offset: 0) @filter(allofterms(name, "Lydia  Spirits"),) {    				 
           uid
           name           
    }
}

The above qn is becs of where the pagination arguments are part of and whether it gets applied after all conditions are evaluated ? Both Students and Teachers can have name “Lydia Spirits”

Note: I can always have explicit predicates like student_name, teacher_name but wanna understand how it will behave in above cases.

From what I understand, the filter is executed after the root filter and pagination, just as it reads. To paginate that after applying multiple filters, you could:

{
  set as var(func: type(Student)) @filter(allofterms(name, "Lydia  Spirits")) # or vise-versa, which ever filters to a smaller set faster
  student(func: uid(set), first: 10, offset: 0){
    uid
    name
  }
}

(feel free to correct me anyone who knows better, answering from recollection)

Thanks @illuminae!

No, I believe, root function, then @filter, then pagination

1 Like

whelp, thanks for the correction. I knew I should have tested it before replying.