Pagination with Offset in Druid

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

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

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

No