-
Notifications
You must be signed in to change notification settings - Fork 679
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
Add extra if in pseudocode fetch all docs #2691
Conversation
"You can repeat this process until you’ve fetched as many docs as you want, or until the nextCursorMark returned matches the cursorMark you’ve already specified — indicating that there are no more results." The pseudo code misses the first part. The extra if also prevents an unnecessary extra request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think pseudo code by it's nature can be lengthier if that helps clarity!
"You can repeat this process until you’ve fetched as many docs as you want, or until the nextCursorMark returned matches the cursorMark you’ve already specified — indicating that there are no more results." The pseudo code misses the first part. The extra if also prevents an unnecessary extra request.
Thank you! |
Hmmmm.... IMO this change does not seem like an overall improvement to the doc First off, the premise of the PR seems to conflate two diff scenarios...
There is a difference between the "until you’ve fetched as many docs as you want" scenario (ie: "I as a client want to fetch docs from solr until i have enough to satisfy my purposes" - there is a separate example for that later in the doc) and "solr ran out of documents to return" scenario being demonstrated here. Adding a "did solr return the full number of rows requested?" check to the code doesn't do anything to demonstrate the first scenario Second: If we're going to change this pseudo code block to do an explicit rows check, then the example should probably note it's an optimization, and the other psuedo code example in the later section on "tailing a cursor" should have a note that you can't use that optimization in this situation. Third:
...but now the psuedo-code and SolrJ code no longer match. Likewise the sequential "curl" example (following the SolrJ example) no longer mtaches either, because it still does a final request looking or an unchanged |
I knew I was going to get in trouble with pseudo code...! I'll roll this back. |
and we can fix the |
:) ... you just gotta remember to review the whole doc holistically.
I don't have a strong opinion ... The idea once upon a time was to avoid the implication to new users that they had to use SolrJ (or python, or whatever) to achieve certain goals. If you want to rip out the psuedo-code i'm fine with that, but it means re-rwiting all the other examples to use SolrJ (and i don't think this is the only page in the ref-guide with psuedo code?) |
Description
"You can repeat this process until you’ve fetched as many docs as you want, or until the nextCursorMark returned matches the cursorMark you’ve already specified — indicating that there are no more results."
The pseudo code misses the first part.
Solution
Add an extra if for checking whether the number of documents in the result is less than the specified rows. The extra if also prevents an unnecessary extra request.
It could also be shortened, by replacing the two ifs by:
$done = count($results[response][docs]) < $r || $params[cursorMark] == $results[nextCursorMark]
I don't know whether that's good for readability.
In addition this could be transformed into a
do while
statement.Tests
None. This is a documentation change.
Checklist
Please review the following and check all that apply:
main
branch../gradlew check
.Not all of the above is checked, because it is a documentation change.