-
Notifications
You must be signed in to change notification settings - Fork 50
Refactor search controller for consistency and clarity #778
Conversation
This reverts commit 7e009fd.
API Developer Docs Preview: Ready https://wordpress.github.io/openverse-api/_preview/778 Please note that GitHub pages takes a little time to deploy newly pushed code, if the links above don't work or you see old versions, wait 5 minutes and try again. You can check the GitHub pages deployment action list to see the current status of the deployments. |
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.
Approving as we have already approved this PR before :) Really hope it works now that the API is throttled for unauthorized requests.
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.
As I was last time, I am still uncomfortable with the size and scope of this refactor. Even though I do agree it seems to make things much more uniform and consistent. I'm not sure that for me it makes anything clearer; perhaps for someone already familiar with the code it does though!
I left one suggestion that might help clarify at least a small part of the code. I think a lot of the code is pretty cryptic to begin with and I hope we can refactor/add tests/add comments to help with that in the future.
If there is absolutely any way to break up this refactor and to deploy it in steps, I think that would be a benefit, but I can appreciate that that is not always possible.
|
||
:param query_serializer: the ``MediaSearchRequestSerializer`` object with the query | ||
:param index: The Elasticsearch index to search (e.g. 'image') | ||
:param ip: the users' hashed IP to consistently route to the same ES shard |
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 is interesting, I didn't know we did this. I wonder if circumventing ES's built-in load balancing could be an issue for us.
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 don't know enough to comment if it can be a problem, but I can see how redirecting all requests from a particularly active consumer to a single shard can be a bottleneck. I haven't modified it in this PR though, it's been that way from before.
I'm going to merge this so that we can unblock #776. It's very huge and unwieldy as-is so it's better for any changes to this to be addressed in faster, smaller, easier-to-review PRs. |
* Revert "Fix related media endpoint (#808)" This reverts commit d7962f1. * Selectively revert "Add logging and fix all logging contexts (#790)" This reverts commit ce33572. * Revert "Refactor search controller for consistency and clarity (#778)" Preserves #730 This reverts commit d26df92. * Fix divergent Elasticsearch configurations In #712 Elasticsearch configuration was moved out of the search controller area into the Django settings module. This unifies access to ES from across the application and is part of the refactoring being done to support the ES versioned index, multi-stage deployment. This commit keeps those changes and applies them to the old search_controller.py module that did not exist at the time the configuration change was applied. * Lint * Prevent circular import We can replace the Any back with the serializer type in the future. * Add back related media endpoint integration tests * Lint
This is a revision of PR #699 formed by reverting commit 7e009fd and then rebasing against
main
.Original description
Testing Instructions
This is a refactor, passing CI should be sufficient proof that no functionality is impacted.
Checklist
Update index.md
).main
) or a parent feature branch.Developer Certificate of Origin
Developer Certificate of Origin