Skip to content

Show an example of how to use cursor traversal #359

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

Merged
merged 1 commit into from
Jan 23, 2021

Conversation

ke4roh
Copy link
Contributor

@ke4roh ke4roh commented Jan 22, 2021

I've looked up cursor traversal in the test enough times to figure it's worth putting it in the readme.

@codecov
Copy link

codecov bot commented Jan 23, 2021

Codecov Report

Merging #359 (f50c065) into master (cf6e49f) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #359   +/-   ##
=======================================
  Coverage   91.52%   91.52%           
=======================================
  Files           7        7           
  Lines        1369     1369           
=======================================
  Hits         1253     1253           
  Misses        116      116           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cf6e49f...f50c065. Read the comment docs.

@acdha acdha merged commit da6082f into django-haystack:master Jan 23, 2021
@acdha
Copy link
Collaborator

acdha commented Jan 23, 2021

Thanks!

@AliVerses
Copy link

why its running in infine loop,
first cursor * it should stop
when i'll hit again with nextcursor it will give next set of result
right?

@ke4roh
Copy link
Contributor Author

ke4roh commented Feb 8, 2021

I'm not sure. I forgot to include sort order (which Solr requires) in the parameters, so you would get an error without that, but otherwise, you should be able to use the iterator over the result set and get ALL of the results. Maybe you are getting more results than you expected? Have a look at the tests for this functionality and see if that covers your situation.

@AliVerses
Copy link

I guess its not working how pagination expected to work
results = solr.search(q=':', cursorMark="*", rows=2, sort="id asc")
this should return only two rows with netxCursorMark="879chwodfgw9eiofsiodcgufio"
and next search query will be

results = solr.search(q=':', cursorMark="879chwodfgw9eiofsiodcgufio", rows=2, sort="id asc")
this will return next 2 records with netxCursorMark="ouji89vnwvebuvwoepojveniowviwonv"

results = solr.search(q=':', cursorMark="ouji89vnwvebuvwoepojveniowviwonv", rows=10, sort="id asc")
this will return next 10 records with netxCursorMark="9odoucwenu9hwe0ewijvw"

and so on.

but now if I have 1M records its. iterating all over which is not expected

same explained here

https://lucene.apache.org/solr/guide/8_6/pagination-of-results.html

@ke4roh
Copy link
Contributor Author

ke4roh commented Feb 8, 2021

PySolr will operate the cursorMark and perform subsequent queries for you when you iterate on a result having a cursor mark, as per the feature we're discussing here. If you want only the results from that singular trip to Solr, use result.docs.

If that doesn't help with your question, could you try to write a failing test?

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

Successfully merging this pull request may close these issues.

3 participants