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

Use endpoints official client #1277

Merged
merged 6 commits into from
Mar 27, 2017
Merged

Use endpoints official client #1277

merged 6 commits into from
Mar 27, 2017

Conversation

ewgRa
Copy link
Contributor

@ewgRa ewgRa commented Mar 23, 2017

This PR start using Endpoints from official client.

There is still places where raw request used, but they require more work and can be done later, during some refactoring. For example official client for Bulk and similar multi requests require SerializerInterface, and there is research needed, can Elastica use Serializer from official client.

This PR cover most cases.

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.

The more I see from this change the more I start to like it. Now in case things change on the API side either it is fixed "automatically" on the elasticsearch-php side or we get notified, that the method does not exist anymore.

Should we create a "meta" github issue to track the changes which are more complicated and are not done yet?

@@ -406,7 +424,10 @@ public function addAlias($name, $replace = false)

$data['actions'][] = ['add' => ['index' => $this->getName(), 'alias' => $name]];

return $this->getClient()->request($path, Request::POST, $data);
$endpoint = new Update();
Copy link
Owner

Choose a reason for hiding this comment

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

Do we also have to add the index name here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it is in "$data".

Actually here we need to use https://github.com/elastic/elasticsearch-php/blob/master/src/Elasticsearch/Endpoints/Indices/Alias/Put.php, but I don't quickly find a way to work with "$replace" argument there. Any suggestion?

Copy link
Owner

Choose a reason for hiding this comment

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

Not sure I can follow the above comment?

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 just mean that we need use Put endpoint there, but I don't find a way how to process $replace flag there. So, it can be tricky and need more time and can be done later. And asking maybe you see quick solution for this. So, we can do this later.

Copy link
Owner

Choose a reason for hiding this comment

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

Got it, also not sure how to deal with it. Lets merge it as is.

@@ -420,11 +441,10 @@ public function addAlias($name, $replace = false)
*/
public function removeAlias($name)
{
$path = '_aliases';
$endpoint = new \Elasticsearch\Endpoints\Indices\Alias\Delete();
$endpoint->setName($name);
Copy link
Owner

Choose a reason for hiding this comment

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

Do we also need the index name here? It was part of the request before ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it is not needed, since we call $this->requestEndpoint(...) it will add index name there.

foreach ($params as $param) {
$path .= $param.',';
}
$endpoint->setMetric(join(',', $params));
Copy link
Owner

Choose a reason for hiding this comment

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

Nice.

Copy link
Contributor Author

@ewgRa ewgRa Mar 24, 2017

Choose a reason for hiding this comment

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

Wow, I just checked official client code, "join" even not needed, we can call setMetric with array, https://github.com/elastic/elasticsearch-php/blob/master/src/Elasticsearch/Endpoints/Cluster/Nodes/Info.php#L31 . Will change it at evening and looks like we haven't test for this case.

Copy link
Owner

Choose a reason for hiding this comment

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

Even better.Ping me when done.

@ewgRa
Copy link
Contributor Author

ewgRa commented Mar 24, 2017

I think "meta" is not needed. It is easy to find places that can be ported to Endpoints. Just check "usage" of "request" function in Type, Index and Client. For now mostly such places left in Client.

@ewgRa
Copy link
Contributor Author

ewgRa commented Mar 24, 2017

Looks loke all done, ping @ruflin

@ruflin ruflin merged commit fcf2bc3 into ruflin:master Mar 27, 2017
@ruflin
Copy link
Owner

ruflin commented Mar 27, 2017

@ewgRa Merged. Thanks.

mhernik pushed a commit to mhernik/Elastica that referenced this pull request Jul 24, 2017
* Official client usage for endpoints
* drop unused use and use index requestEndpoint
* better usage of setMetric
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