Document position in Index

Hi,
When a document qualified to be indexed, is possible to get the position of this document in the index? I know I can get a count of all indexed documents of one index, but can I get somethig like:

document doc_id::873 is in position 8 in index “idx_A” and position 10 in index “idx_B”?

is there index position in first place?

In a relational schema, it would be like a num_row of a row in table.

Thanks for any help.

Indexes uses b-tree type of structures and it is not possible. document key is primary key you can use that retrieve the document.

Right, but when I define indexes and queries like:

(A) create index idx_date on BUCKET(date DESC)
(B) create index idx_type on BUCKET(type)

© select meta().id from BUCKET where date < NOW_MILLIS() limit 5
(D) select meta().id from BUCKET where type = “book” limit 10

And try to push down limit/offeset to one of this indexes with queries like © or (D), the order of the documents matters. Because, if I have a document doc_id::6 indexed in both indexes (A) and (B), in query © is always my first document in list but in (D) is always my third document, because to push down to indexscan, the order of the documents is inherited from each index.

that is why despite being a b-tree, there must be an order in its sheets (documents) and I do not know if it is possible to obtain these positions.

Please help.

Unless If you specify Query ORDER BY, results will never be guaranteed any specific order.
If query Order matches index keys order and all predicates are pushed to indexer and no false positives are possible, query uses index order, offset and limit are pushed to indexer.

https://blog.couchbase.com/n1ql-practical-guide-second-edition/

https://docs.couchbase.com/server/5.1/performance/index_pushdowns.html