Skip to content
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

Merged

Conversation

giovannialbero1992
Copy link
Contributor

{
$body = self::getBody($oldIndex, $newIndex, $options);

$reindexEndpoint = new \Elasticsearch\Endpoints\Reindex();
Copy link
Owner

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 👍

const SIZE = 'size';
const QUERY = 'query';

public static function reindex(Index $oldIndex, Index $newIndex, array $options = [])
Copy link
Owner

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.

Copy link
Contributor Author

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 ?

Copy link
Owner

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?

Copy link
Contributor Author

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.

@giovannialbero1992 giovannialbero1992 force-pushed the deprecate_cross_index_and_add_reindex branch from 417d53e to 974b6e9 Compare May 22, 2017 15:14
@giovannialbero1992
Copy link
Contributor Author

@ruflin I've removed static from class and renamed method in run. What do you think about this version?

Copy link
Owner

@ruflin ruflin left a 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.

/**
* @var Index
*/
private $oldIndex;
Copy link
Owner

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.

Copy link
Contributor Author

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 :)

/**
* @var Index
*/
private $newIndex;
Copy link
Owner

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.

return $this->newIndex;
}

private function getBody($oldIndex, $newIndex, $options)
Copy link
Owner

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.

@giovannialbero1992 giovannialbero1992 force-pushed the deprecate_cross_index_and_add_reindex branch from 974b6e9 to 5906153 Compare May 23, 2017 14:03
@giovannialbero1992
Copy link
Contributor Author

@ruflin, I've changed it :)

@giovannialbero1992 giovannialbero1992 force-pushed the deprecate_cross_index_and_add_reindex branch from 5906153 to 497f298 Compare May 23, 2017 14:19
Copy link
Owner

@ruflin ruflin left a 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.

/**
* @var array
*/
private $_options;
Copy link
Owner

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.

return $this->_newIndex;
}

protected function getBody($oldIndex, $newIndex, $options)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be _getBody(

], $this->resolveDestOptions($options));
}

private static function resolveSourceOptions(array $options)
Copy link
Owner

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.

@giovannialbero1992 giovannialbero1992 force-pushed the deprecate_cross_index_and_add_reindex branch from 497f298 to eb49b81 Compare May 26, 2017 06:04
@giovannialbero1992
Copy link
Contributor Author

@ruflin I've changed all names with '_' and removed a missing static from method.
_getDestPartBody, _getSourcePartBody and _getBody now are protected. Thanks for your reviews :)

@ruflin ruflin merged commit 8e2d474 into ruflin:master May 26, 2017
@ruflin
Copy link
Owner

ruflin commented May 26, 2017

@giovannialbero1992 Thanks for your contribution.

mhernik pushed a commit to mhernik/Elastica that referenced this pull request Jul 24, 2017
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
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.

2 participants