-
Notifications
You must be signed in to change notification settings - Fork 729
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 Reindex and deprecated CrossIndex #1315
Added Reindex and deprecated CrossIndex #1315
Conversation
lib/Elastica/Reindex.php
Outdated
{ | ||
$body = self::getBody($oldIndex, $newIndex, $options); | ||
|
||
$reindexEndpoint = new \Elasticsearch\Endpoints\Reindex(); |
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.
glad to see you used the endpoints 👍
lib/Elastica/Reindex.php
Outdated
const SIZE = 'size'; | ||
const QUERY = 'query'; | ||
|
||
public static function reindex(Index $oldIndex, Index $newIndex, array $options = []) |
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.
Why did you use static method here? I'm thinking the implementation would become simpler if you would use a Reindex object where old, new and options are passed.
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've used static method because there are not external depenendencies but maybe, to be compliant with OOP I should remove static. Do you suggest to pass parameters into constructor or in reindex method ?
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 thinking passing params to constructor and then having something like $reindex->Run()
or Start
or something similar. Perhaps Start() could also take additional options. Not 100% sure yet how the most common use case will look like. Any thoughts?
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 that call new
and ->run()
(or ->start()
) are ever near to constructor and there is no need to change options after have called new Reindex(...)
. Maybe in a first time we can see how community uses reindex and if there will be need to change the use, we will change it consequently.
417d53e
to
974b6e9
Compare
@ruflin I've removed static from class and renamed method in |
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.
Left some minor comments. Code LGTM. Thanks for adding the functional test.
lib/Elastica/Reindex.php
Outdated
/** | ||
* @var Index | ||
*/ | ||
private $oldIndex; |
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.
We always use $_oldIndex for all the variable names which are private / protected but perhaps the time has come to break this as not much other projects are left with the old pattern.
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 changed to be compliant with old pattern... maybe we can change the pattern into another commit on all protected/private variables :)
lib/Elastica/Reindex.php
Outdated
/** | ||
* @var Index | ||
*/ | ||
private $newIndex; |
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.
Please make these all protected and not private. In case someone wants to extend Reindex in his code, he should be able to.
lib/Elastica/Reindex.php
Outdated
return $this->newIndex; | ||
} | ||
|
||
private function getBody($oldIndex, $newIndex, $options) |
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.
Make these also protected, not private.
974b6e9
to
5906153
Compare
@ruflin, I've changed it :) |
5906153
to
497f298
Compare
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.
Can you apply to change to all variables and methods. I didn't leave a comment for all of them.
About the "naming changed": It would be great if there is a script that could do all this renaming for us. Not sure if there is a tool that can do this.
lib/Elastica/Reindex.php
Outdated
/** | ||
* @var array | ||
*/ | ||
private $_options; |
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.
This one should also be protected.
lib/Elastica/Reindex.php
Outdated
return $this->_newIndex; | ||
} | ||
|
||
protected function getBody($oldIndex, $newIndex, $options) |
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.
This would be _getBody(
lib/Elastica/Reindex.php
Outdated
], $this->resolveDestOptions($options)); | ||
} | ||
|
||
private static function resolveSourceOptions(array $options) |
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.
This should also be not static and start with _* Also make it protected if there is no need to make it private.
497f298
to
eb49b81
Compare
@ruflin I've changed all names with '_' and removed a missing static from method. |
@giovannialbero1992 Thanks for your contribution. |
added changelog entry and asserts to config test added SpanOrTest added SpanMulti span functions in dsl query updated removed unnecessary attributes reverted docker ip range Changelog update Changelog update
#1311