-
Notifications
You must be signed in to change notification settings - Fork 317
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
BUG: ep_weighting_configuration_for_search filter not applied if using fallback default weight config #3132
Comments
Hi @andyblackwell, I'm sorry but I'm having a hard time understanding the use case you have at hand here. The array manipulated by the
The test introduced in #3303 checks that. I probably got your point wrongly but even when the option is empty (the weighting config was not saved), it will use the filter.
That is really not needed if you know the post type slug (and that should be the case, no?) Also, using the dashboard to change those values would always be preferable. Regarding "only during search, and not while in the admin or while saving", weighting is not applied during content saving (unless you are talking about something else?), and should not be used in admin unless the value passed through the Do you mind clarifying the scenario you have at hand a bit more? Thanks in advance! |
added some comments to demonstrate the issue
To get around this, we had to add/remove another filter on the default config itself all that said, I personally don't need this fix anymore since the place I worked for did a big layoff this week 😢 ... and we had already worked around the issue, were just hoping to remove the hack/workaround in the future |
Hey @andyblackwell, I'm super sorry to read your last paragraph there and I hope you find a good place to work asap (10up is hiring, by the way.) Going back to our problem, something like the code below should be enough. I'm still unclear about why you'd need to be careful with it, as it would only affect post types that didn't have any changes applied in the Weighting Dashboard. add_filter(
'ep_weighting_default_post_type_weights',
function ( $defaults ) {
$defaults['post_content_filtered'] = [
'enabled' => true,
'weight' => 1,
];
return $defaults;
}
); Would it be possible to share the code you ended up with? Thanks |
This issue has been automatically closed because there has been no response to our request for more information. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further. See this blog post on bug reports and the importance of repro steps for more information about the kind of information that may be helpful. |
when using the
ep_weighting_configuration_for_search
filter, it is not applied when the plugin code needs to backfill with a default weight config for a post typehttps://github.com/10up/ElasticPress/blob/4.3.1/includes/classes/Feature/Search/Weighting.php#L580-L590
https://github.com/10up/ElasticPress/blob/4.3.1/includes/classes/Feature/Search/Weighting.php#L531-L547
common case: when the weighting configs have not been manually saved in the admin
another possible use case: a new custom post type has been created since the last time the weighting config has been saved
in these cases the fallback to the default weight config will bypass the
ep_weighting_configuration_for_search
filter entirely, requiring a bit of a hack to also filter the defaults viaep_weighting_default_post_type_weights
and having to be careful only to do that in the correct scenarios (only during search, and not while in the admin or while saving)Steps to Reproduce
ep_weighting_configuration_for_search
filter, like as described in: https://elasticpress.zendesk.com/hc/en-us/articles/4402857301389Expected behavior
that the
ep_weighting_configuration_for_search
filter is applied regardless of whether or not the weighting config has been savedEnvironment information
The text was updated successfully, but these errors were encountered: