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

Add a Comments Indexable #1531

Merged
merged 109 commits into from
Jun 28, 2021
Merged

Add a Comments Indexable #1531

merged 109 commits into from
Jun 28, 2021

Conversation

dkotter
Copy link
Contributor

@dkotter dkotter commented Oct 18, 2019

Description of the Change

Similar to #1443, a new filter was added to WordPress core and is coming in 5.3 that allows comment queries to be short-circuited with your own results. This provides ElasticPress the ability to take over any queries that utilize WP_Comment_Query.

This PR adds a new Comments Indexable that will index all comments across a site (regardless of comment type or status) and then takes over WP_Comment_Query if ep_integrate is true or if the search argument is used.

Benefits

Comments will now be stored in elasticsearch and can be searched across as needed. Any queries that make use of WP_Comment_Query, either directly or indirectly, can gain potential performance benefits by utilizing an elasticsearch query over a traditional database query.

Possible Drawbacks

Not all queries will be made faster by this integration, so testing will need to be done to determine if it's worth using elasticsearch for comment queries in all situations.

Verification Process

Tested these changes locally on a multisite install, with 4 sites on the network. Each site had a handful of comments, some of these had replies, others did not.

  • Verified that running a full index will add all comment information into a new comments index within elasticsearch.
  • Verified that adding a new comment or updating an existing comment (in the admin) will add/update that comment within the correct index
  • Verified that running a WP_Comment_Query, with ep_integrate set to true, runs the query against elasticsearch
  • Tested all the various query params that WP_Comment_Query supports, to make sure those work when run against elasticsearch

Note further testing is recommended here, to further ensure all the various query params work, especially when used in conjunction with each other.

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests passed.

@jeffpaul jeffpaul requested a review from tlovett1 October 18, 2019 21:01
@jeffpaul jeffpaul added this to the 3.3.0 milestone Oct 18, 2019
@tlovett1 tlovett1 removed this from the 3.3.0 milestone Oct 28, 2019
@jeffpaul
Copy link
Member

jeffpaul commented Nov 5, 2019

@brandwaffle @tlovett1 @tott please let me know once this gets through code review and if there are any changes needed from that review... thanks!

@Rahmon
Copy link
Contributor

Rahmon commented Jun 21, 2021

@Rahmon , while testing this, I noticed a couple of things:

With WooCommerce and Protected Content enabled:

  1. Although it won't index WC order notes during the bulk index, the order note will get indexed if you create a new one directly into a WC order. We'll need to tweak ElasticPress\Indexable\Comment\SyncManager::action_sync_on_update to avoid that.
  2. I had some unapproved comments stored, one of them was I want to learn how to make chinese eggrolls (I really don't know from where it came). Going to /wp-admin/edit-comments.php?s=chinese, I can see 2 queries being sent to ES, none of them with results BUT I can see the comment is listed. So we'll need to check why we have 2 queries and why it is querying MySQL anyway.

@felipeelia thanks for the review 🙏

(1) I've fixed this issue and added some tests.

(2) I've updated to better integrate with Protected Content enabled. However, I noticed that the Comments page does a lot of queries to retrieve the comments.

@Rahmon Rahmon assigned felipeelia and unassigned Rahmon Jun 21, 2021
@Rahmon Rahmon mentioned this pull request Jun 24, 2021
6 tasks
@felipeelia
Copy link
Member

@Rahmon assigning back to you to sort the last issue with WC orders and client notes as we've discussed. Thanks!

@felipeelia felipeelia assigned Rahmon and unassigned felipeelia Jun 24, 2021
@Rahmon Rahmon assigned felipeelia and unassigned Rahmon Jun 24, 2021
@felipeelia felipeelia merged commit a01271b into develop Jun 28, 2021
@felipeelia felipeelia deleted the feature/comments-indexable branch June 28, 2021 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants