Pagination with Offset in Druid

1,111 views
Skip to first unread message

Pravesh Gupta

unread,
Jan 19, 2017, 4:24:50 AM1/19/17
to Druid User
Hi,
Is Pagination with start Offset supported in Druid.

Given my Page Size is 100, If I go from Page 1 to Page 2, is there any way I can get results from 100 till 200 ?
Currently I am using "threshold" field and for above use case getting  2 * 100 = 200 rows , which i feel is not good from improvement point of view.

Is there anything like start_offset ?

I hope I am able to make my self clear here.

Thanks,
Pravesh Gupta

Ankush Kapur

unread,
Jan 19, 2017, 11:41:08 AM1/19/17
to Druid User
Hi Pravesh,

Assuming you are asking about paging with a Select query.

The key to paging in a select query is to use pagingSpec object with the appropriate paging identifiers, as mentioned here, http://druid.io/docs/latest/querying/select-query.html

When you request the first page, there will be no pagingIdentifiers,

"pagingSpec":{"pagingIdentifiers": {}, "threshold":100}

The response object for this query will have pagingIndentifiers that you need to use for the subsequent page.

    "pagingIdentifiers" : {
      "wikipedia_2012-12-29T00:00:00.000Z_2013-01-10T08:00:00.000Z_2013-01-10T08:13:47.830Z_v9" : 4
    },

So for the next page (page 2), you need to increment the segment offsets and include them in your request.

"pagingSpec":{"pagingIdentifiers": {"wikipedia_2012-12-29T00:00:00.000Z_2013-01-10T08:00:00.000Z_2013-01-10T08:13:47.830Z_v9" : 100}, "threshold":5}


If you want druid to perform the increment/decrement itself then include "fromNext": true in your property.(refer to the select query documentation)

Keep in mind, you need to include segments offsets from all previous requests for subsequent pages.

Hope this help

Ankush

Pravesh Gupta

unread,
Jan 19, 2017, 11:46:19 AM1/19/17
to Druid User
Thanks Ankush for the details.

I was actually asking for TopN Query type.
Is there any way to do what u described with TopN query , or Select Query is the only option.

Thanks,
Pravesh Gupta

Slim Bouguerra

unread,
Jan 20, 2017, 10:38:38 AM1/20/17
to druid...@googlegroups.com
No
-- 

B-Slim
_______/\/\/\_______/\/\/\_______/\/\/\_______/\/\/\_______/\/\/\_______

--
You received this message because you are subscribed to the Google Groups "Druid User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to druid-user+...@googlegroups.com.
To post to this group, send email to druid...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/druid-user/a32aecb4-aba4-4312-af14-54bd5a8dc228%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages