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

CANTINA-1000: Prevent impact of filtered formatted ES args when wp vip-search health validate-counts runs #5058

Merged
merged 1 commit into from
Nov 30, 2023

Conversation

rebeccahum
Copy link
Contributor

@rebeccahum rebeccahum commented Nov 27, 2023

Description

Since wp vip-search health validate-counts ultimately calls $indexable->format_args() which applies the ep_formatted_args filter, it can return the incorrect results for counting ES entities if it's filtered improperly.

Example #1:

add_filter('ep_formatted_args', function ($formatted_args, $args, $wp_query) {
    $formatted_args['test'] = 1.2;

    return $formatted_args;
}, 25, 3);

There's no ES test parameter, so this breaks the ES query and results in the below when we run wp vip-search health validate-counts:

Warning: Error while validating count: failure querying ES. #vip-search
Warning: Error while validating count: failure querying ES. #vip-search

Example #2:

add_filter('ep_formatted_args', function ($formatted_args, $args, $wp_query) {
    $formatted_args['min_score'] = 3;

    return $formatted_args;
}, 25, 3);

Since we're using a high minimum scoring of 3 and there may be no documents are scoring above 3 with the way ES uses the TF/IDF scoring model, it returns 0 results, which is not what we want if we just want to validate the general ES document counts. This would be the result when we run wp vip-search health validate-counts:

🟧 skipping, because there are no documents in ES when counting entity: post, type: post, index_version: 1
🟧 skipping, because there are no documents in ES when counting entity: post, type: page, index_version: 1

Changelog Description

Plugin Updated: Enterprise Search

Prevent impact of filtered formatted ES args when wp vip-search health validate-counts runs

Pre-review checklist

Please make sure the items below have been covered before requesting a review:

  • This change works and has been tested locally (or has an appropriate fallback).
  • This change works and has been tested on a Go sandbox.
  • This change has relevant unit tests (if applicable).
  • This change uses a rollout method to ease with deployment (if applicable - especially for large scale actions that require writes).
  • This change has relevant documentation additions / updates (if applicable).
  • I've created a changelog description that aligns with the provided examples.

Pre-deploy checklist

  • VIP staff: Ensure any alerts added/updated conform to internal standards (see internal documentation).

Steps to Test

  1. Try out both scenarios mentioned in the description and ensure that they return the expected results when running wp vip-search health validate-counts

Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@rebeccahum rebeccahum added the [Component] Search ChangelogTagID: 2373 label Nov 27, 2023
@rebeccahum rebeccahum marked this pull request as ready for review November 27, 2023 23:54
@rebeccahum rebeccahum requested a review from a team as a code owner November 27, 2023 23:55
Copy link

codecov bot commented Nov 27, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (122e5a0) 28.89% compared to head (677b20f) 28.83%.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #5058      +/-   ##
=============================================
- Coverage      28.89%   28.83%   -0.07%     
  Complexity      4752     4752              
=============================================
  Files            278      278              
  Lines          20931    20921      -10     
=============================================
- Hits            6049     6033      -16     
- Misses         14882    14888       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rebeccahum rebeccahum merged commit 19b58dd into develop Nov 30, 2023
40 checks passed
@rebeccahum rebeccahum deleted the fix/cantina-1000 branch November 30, 2023 14:42
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.

2 participants