-
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
Up to elasticsearch 8 #2181
Up to elasticsearch 8 #2181
Conversation
Great work @pawelkeska ! I thought refactoring the Client would've been much more work... What I find a bit difficult is to follow the flows because there's little to no typehinting in the function parameters or return statements so I'll have to ask :D How is for example the Client->index($params) returning an Elastica Response object? I can't seem to find the index() function on the Client and there's no typehinting to go on... I'm just trying to understand the changes, but aside from that, thanks so much for the contribution @pawelkeska ! |
It looks promissing @pawelkeska. Thanks for your efforts. My 2 cents: So I'd suggest to set minimum version equal to 8.4 |
Up. |
@pawelkeska Thansk for picking this up. Trying to find the time to give you a detailed review. |
Up. |
Thank you @pawelkeska for the massive amount of work you put into this! I like the direction this is taking. There will be breaking changes for users going to 8 but there is no way to prevent it. Also looking at the tests, the changes users have to do are less then I expected. There are 2-3 changes where I wonder if we could with low effort make the migration easier. Could we for example "wrap" Elasticsearch object into the old Response object so the Response object would stay the same? The second is around Seems like along the way, you also cleaned up some of the code, thanks! One nice thing would be having a very short write up on how users would have to migrate from 7.x to 8.x. What do 80% of the users have to change to be successful and get things working quickly? The tests already show part of this pretty well but it would be nice to have it summarised. The most important thing at the moment is I think getting a version out of the door (even beta) that works with 8.x. We can add more "convenience" functions later on that help with migration if many users bump into it. @pawelkeska How close are we to have such a first version? |
{ | ||
parent::__construct($response->getData(), $response->getStatus()); | ||
|
||
$this->setQueryTime($response->getQueryTime()); |
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 guess this is not available anymore?
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.
Yes, i have to remove property $_queryTime from Response object.
* @throws ConnectionException | ||
* @throws ResponseException | ||
*/ | ||
public function request(string $path, string $method = Request::GET, $data = [], array $query = [], string $contentType = Request::DEFAULT_CONTENT_TYPE): Response |
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.
Is there a way to at keep this method at least with the parameters? I expect this to be used a lot.
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.
Yes, of course we could keep this method but i think users should start using actions from trait ClientEndpointsTrait. This gives them greater consistency and benefits in further maintaining the application.
* | ||
* @return string | ||
*/ | ||
public static function convertRequestToCurlCommand(Request $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.
This was for debugging purpose if I remember correctly. Not compatible anymore?
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.
yes, it was used in utils test function testConvertRequestToCurlCommand but this function was not used anywhere in the tests.
tests/ClientFunctionalTest.php
Outdated
@@ -277,7 +279,7 @@ public function testDeleteIdsIdxString(): void | |||
// Refresh index | |||
$index->refresh(); | |||
|
|||
$resultData = $result->getData(); |
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.
If we would have a wrapper around result, get we keep getData as a proxy for asArray?
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 need to think about it, I explained everything in the comment.
Thanks @ruflin Yes, we can "wrap" Elasticsearch by old object Response but only Elastica actions like "updateDocument", "addDocuments" etc In my free time, I will try to write in changelog about what has changed. After making a decision, what do we do with Response object i think we can release the first beta version. |
I like the idea but I don't know how much work it is. The main reason I would wrap it is for migration purposes. How much work does it take for a user migration from 7.x to 8.x? If we save everyone with this changes a few minutes and troubles searching for the solution, it sums up quickly and creates happier devs :-) But if it makes our code much more complex and hard to maintain, it is not worth it. It's all a trade off. @pawelkeska Can you anticpate how much work it would be to do the "wrapper" approach for response? I could also see us releasing a first version as alpha without the response wrapper and actively ask for feedback from first users (not sure how, maybe through the changelog) on how hard the migration was for them and what they would like to be changed / made easier. If everyone is happy, the additional code might not be needed. At the same time, I have a strong feeling it will help many users. |
We - @pryserv and I from valantic - make heavy use of Elastica through What would you like us to test, what would be the best approach for us to contribute and help getting support for Elasticsearch 8 in a stable version of Elastica? |
@limenet I would really appreciate yours and @pryserv help on this. Step one to get us moving forward is getting this PR over the line and then go for the testing. Please have a look at the code and discussions and provide your opinions / insights. There is also some failing tests on this PR, could help fix these. I guess you will not have permissions to push to the branch but open a PR against the branch and we can get it in quickly? |
Fix all tests and CS/DX. @ruflin we can release an alpha version but someone has to write the changelog. |
@ruflin @pawelkeska Thank you! I'm working on valantic/pimcore-elastica-bridge#55 and upgrading a Pimcore project to Pimcore 11 and Elasticsearch 8. If/when we encounter issues during testing, I'll try to fix the issue and submit a PR or comment here, if that works for you?
This sounds like a good plan and I'll try to get to it this/next week. |
@pawelkeska Thanks for the very quick turnaround. I can think of three options moving forward:
The only reason I would do 8.x-alpha is in case some users are running based on 8.x and this would break their code, at the same time what they have with 8.x would not work against 8.x properly anyways. If we keep the branch open, it causes work fro @pawelkeska to merge PR's instead of doing the work on my side. So I'm leaning towards option 1, get this in and take it from there. What we should do on top of Option 1 is likely update the README to indicate that the current branch is no stable yet. Thoughts? |
@pawelkeska @limenet Lets make a quick call on merging this branch. I'm proposing to get it in as is and take it from there. Any concerns? |
Just would like to highlight #2181 (comment) one more time. It's okay to do it in a separate PR but before any releases. |
@ruflin agree on merging this branch into |
PR is in! Lets continue with follow up PR's / testing etc. |
@pawelkeska THANK YOU for all the effort into this. Also thanks to everyone that contributed code / discussion / ideas to get to this point! |
@pawelkeska amazing work, really! |
@ruflin Thanks, I'm glad I could help. |
@limenet i saw your changes in your repo. From now we dont't have You should use functions from this trait like that |
@pawelkeska thank you for checking out my changes! Other than PHPStan being unhappy about the return type of |
@limenet In our client we have return type |
@pawelkeska the return types are correct but when I run PHPStan (level 8) on: $this->esClient->indices()->existsAlias(['name' => $indexConfig->getName()])->asBool() I get
because |
@limenet Yeap, you are right but we don't use Promise in our Elastica client, but this does not change the fact that we need to check whether a given function exists. The only solution will be use null safe operator
|
I have marked people from PR 2168 because i'd like to continue upgrade to ES8.
Please verify my changes. Now we've got one transport from Elastica and client has been extended by endpoints trait from elasticsearch library. I had to correct some tests.
I didin't use transport from elasticsearch lib because it would require a large number of changes and I marked it as not supported and I think this change will be too big.
@ruflin @VincentLanglet @oleg-andreyev @coreation