-
Notifications
You must be signed in to change notification settings - Fork 736
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
added Scroll Iterator #842
Conversation
Changes Unknown when pulling cfcd3a5 on webdevsHub:scroll into * on ruflin:master*. |
Changes Unknown when pulling 6bf4a0b on webdevsHub:scroll into * on ruflin:master*. |
1 similar comment
Changes Unknown when pulling 6bf4a0b on webdevsHub:scroll into * on ruflin:master*. |
$this->_search->getQuery()->setSize($this->sizePerShard); | ||
// reset state | ||
$this->_nextScrollId = null; | ||
$this->_options = array(null, null, null, null); |
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.
shouldn't it be only 3 null?
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.
Nevermind, I just saw that there is a fourth param size for ScanAndScroll
Does this break an BC or not? |
no |
Changes Unknown when pulling 6bf4a0b on webdevsHub:scroll into * on ruflin:master*. |
Changes Unknown when pulling 6bf4a0b on webdevsHub:scroll into * on ruflin:master*. |
1 similar comment
Changes Unknown when pulling 6bf4a0b on webdevsHub:scroll into * on ruflin:master*. |
I would like hearing @hasumedic opinion on this before merge |
Ok, I will wait with merging until @hasumedic put his feedback in. |
Looking good to me @webdevsHub! |
* | ||
* @var array | ||
*/ | ||
protected $_options = array(null, null, null); |
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.
Should this be a VO instead?
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.
Should this be a VO instead?
VO?
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 was wondering if we should be using Value Objects for these pieces of config. But I haven't seen them implemented anywhere else in the library, so I would assume that arrays are the conventions in this case. Isn't that the case @ruflin?
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.
@hasumedic Currently the convention is arrays. This is mainly related to the history of Elastica as it started very simple and grew together with elasticsearch. If we change to ArrayObjects, we should consider a change across the full library. @ewgRa brought up this issue and I just realised I never responded to it :-( #783 (comment) I suggest to continue this discussion in #783 an until then we use arrays.
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.
That being the case, this PR looks good and should go forward! 👍
I deleted |
Mention it in the CHANGELOG.md file |
Merged. Thx. |
@webdevsHub just a quickie. How would this API work in a cross-request scenario? ie. First request loads the data and returns the scrollId by means of Scroll::key(). Second request sends the scrollId to fetch the next bulk of data. How would this scrollId be set into the Scroll object to query ES for the next set of results? |
@hasumedic I think @webdevsHub is on vacation and will only respond next week ... |
@ruflin that's OK. We'll figure it out then :) Thanks for letting me know! |
@hasumedic scroll id is set in https://github.com/ruflin/Elastica/blob/master/lib/Elastica/Scroll.php#L77 and |
Thanks for replying @webdevsHub ! I guess that that's precisely what my question was. What I was asking in my previous comment was in terms of web requests. So you make a first web request to process a first batch of (lets say) 1000 elements. This generates the scrollId and the first 1000 results. With this you generate a response. Does this make any sense? |
As you can see here it is perfectly fine to use the Iterator without foreach and without setting something manually in the class. |
I'll give it a go. Thanks! |
Implementation of
Scroll
Iterator requested by @hasumedic in #827The
Scroll
Iterator executes every request fully isolated. That means search options manipulated during iterations are changed and reverted automatically.In addition I changed the
ScanAndScroll
Iterator to a child class ofScroll
in order to profit from that isolation.Finally I added a
Search::scroll()
function just likeSearch::scanAndScroll()