lugensa / scorched

Sunburnt offspring solr client
MIT License
27 stars 19 forks source link

Add support for solr cursors #28

Closed Chronial closed 8 years ago

Chronial commented 8 years ago

This adds support for solr cursors (https://cwiki.apache.org/confluence/display/solr/Pagination+of+Results#PaginationofResults-FetchingALargeNumberofSortedResults:Cursors)

lugensa commented 8 years ago

@Chronial

Hi,

cursors seems to be a good improvement and it would nice if we have support for this in sunburnt.

Your pull request looks fine but I am missing support for building solr queries with allready available cursor marks. Our typical use cases are web views which allow paging over a given result set. So far I see your implementation only allows to build queries starting with cursor mark '*'.

Maybe a simple

def cursor(self, constructor=None, rows=None, cursor_mark='*'):
...
    return SolrCursor(search, constructor, cursor_mark)

will fix this. Any idea?

Best regards, Martin

Chronial commented 8 years ago

Mhh, that would not solve that completely, as you don't have access to the current cursor mark in the iterator. Also this seems to be asking for trouble as you have to make sure you send the exact same query as before with the cursor mark. I think a high-level library like scorched should help with this. You could serialize the cursor object and reconstruct it later on – this way you have the current cursor mark and the query together.

But then again, that would be counter-intuitive as you would expect to serialize the current iterator position, but that is not possible (we could try to iterate till we get to the last seen item, but that item might not exist anymore). But this is now a limit of solr, not of this implementation.

Are you sure cursors are the right fit for your situation? How would you go back to a previously visited page?

lugensa commented 8 years ago

@Chronial

Yeah, I see the point. We have lots of traditional web based paging and cursors will not help us (going back/forward; jumping directly to a page).

lugensa commented 8 years ago

And yes,

thanks for the patch :)