How to get position of uid in query results

Using pagination, I’m looking for a way to figure out which “page” of data needs to be displayed to show a specific node (I know its uid). The pagination function “after” is great, though of course it means that the uid in question will always be the first node returned in that query, as opposed to its natural position within a page.

How would I go about finding the “position” of a node in the results of a specific query? maybe just counting the uids until that node? Maybe I’m missing something obvious…


What I’m trying to figure out now is how to have a value that iterates as the query results come in. Is there any way of doing that? Or put another way, a value for count(uid) that is not the final number at the end of the query, but rather an iterator that is updated within each node.

In fact, generally speaking, is there a way to declare and manipulate variables within a search query? (like the mysql user variables using ‘SET @iterator := 1’ syntax)

A position from a paging will be determined by the index (can change depending on the index you choose) used or by the order of UID creation. This is perhaps not desirable, since UIDs are given randomly.

Knowing your indexing, the a way to determine the position is by loading the entire list/paging and and determine its position via the application.

Other way is using “first” set to 1 and go altering “offset:0” - So if you have 40 nodes, you have 39 offsets. It’s a zero based.

I don’t think so. Just checking.

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