Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adding support for OFFSET #31549

Open
astefan opened this issue Jun 25, 2018 · 22 comments
Open

Consider adding support for OFFSET #31549

astefan opened this issue Jun 25, 2018 · 22 comments
Labels

Comments

@astefan
Copy link
Contributor

astefan commented Jun 25, 2018

At the moment, ES SQL supports LIMIT only. Would be helpful to also support OFFSET to allow users to use pagination.

@astefan astefan added the :Analytics/SQL SQL querying label Jun 25, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

@chenrenfei
Copy link

good,please add return total record count for pagination!

@flydocs-jignesh
Copy link

Any hope?

@astefan
Copy link
Contributor Author

astefan commented Sep 16, 2019

@flydocs-jignesh As an update, OFFSET is not on our near future feature list.

@ifooling
Copy link

How long?

@hank583746309
Copy link

I want know how long . can support 'offset' too. dear~

@caihaibin1991
Copy link

me too.... dear ....

@ghost
Copy link

ghost commented Dec 29, 2019

Hope to support offset as soon as possible!!!!

@caihaibin1991
Copy link

I use /_xpack/sql/translate to turn the sql to be es sql, and then append from to strip the offset ....

@leanderli
Copy link

It's really useful.Hope to support it ...

@wdgrantham
Copy link

Just hopping on here. I've been migrating a very large MySQL database over to elastic search to improve search speed. A key part of my application is allowing my users to pull lots of data from my database, and I've historically used offsets to ensure that they don't get duplicate records.

Now that I know that elastic search sql doesn't support offsets, I'm having to write some funky logic to do it manually. For example, where I used to use a simple offset command like this:

SELECT fn, ln, addr from "Db"."Table" WHERE (fn like 'And%') LIMIT 5000 OFFSET 5000

I'm now having to write something like this:

SELECT id, fn, ln, addr from "Db"."Table" WHERE (fn like 'Jam%') and (id > ${last_id_user_downloaded} ) ORDER BY id LIMIT 5000

Then I have to strip the id field from the results of all the rows before I create the download.

Would really appreciate if you all could support OFFSET

@chenrenfei
Copy link

Why not consider pagination by sql?
and provide an example?

@rjernst rjernst added the Team:QL (Deprecated) Meta label for query languages team label May 4, 2020
@Mokaful
Copy link

Mokaful commented Aug 11, 2020

I'm very very very eager for pagination.when can we get it?

@leanderli
Copy link

I'm very very very eager for pagination.when can we get it?

Opendistro-for-elasticsearch SQL support it and powerful.

@sephiroka
Copy link

Does new version's ES-SQL provide solutions to help paging?

@cloder
Copy link

cloder commented Dec 13, 2020

Is there any news about this?

@astefan
Copy link
Contributor Author

astefan commented Dec 14, 2020

OFFSET is not on our map at the moment.
Even though this is not the same, pagination is possible in ES SQL in a performant way through the use of cursors: https://www.elastic.co/guide/en/elasticsearch/reference/master/sql-pagination.html.

@brunoanasofia
Copy link

Hello @astefan. We are in May 2021. Do you still have this issue on your map? I can´t paginate backwards using a cursor. Is there another solution for this problem? Thanks.

@astefan
Copy link
Contributor Author

astefan commented May 27, 2021

@brunoanasofia things are the same as they were in December 2020 (when my latest reply was added).

@ARdreamer
Copy link

Hope to support offset as soon as possible!!!!

@Robbie-Perry
Copy link

@astefan Any updates on this? Seems like it would be something fairly trivial to add, considering elasticsearch querying supports this behaviour with the "from" parameter.

For now, the workaround that I'm doing is as follows:

  • Remove OFFSET clause from SQL
  • Pass SQL into SQL Translate API
  • Manually add "from": n to returned elasticsearch query
  • Pass query into Search API

@edu-de
Copy link

edu-de commented Mar 9, 2023

Hi,
I need also pagination support (with OFFSET or any other similar SQL construct). Is this still planned ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests