Describe the bug
I’m currently implementing a custom search page using ElasticPress by overriding search.php. In this setup, I rely on WP_Query with ep_integrate = true to keep ElasticPress fully active for search results.
However, when the “facets” feature is enabled in the ElasticPress settings, the plugin automatically adds aggregations (faceting) to the query. In my case, I need ElasticPress enabled, but I explicitly want to disable faceting for specific queries.
Problem
Looking at the implementation of is_facetable(), the logic for the ep_is_facetable query argument is effectively treated as a positive-only override:
if ( ! empty( $query->get( 'ep_is_facetable' ) ) ) {
return true;
}
This means that only truthy values are considered, while false is ignored and falls through the rest of the logic.
Because of this behavior, it would be useful and more consistent to explicitly handle the case where ep_is_facetable is set to false, so that faceting can be disabled at query level in a deterministic way.
In particular, a condition such as:
if ( $query->get( 'ep_is_facetable' ) === false ) {
return false;
}
Steps to Reproduce
Insert the following code in functions.php and enable the Filter feature from the plugin settings.
add_action( 'pre_get_posts', 'qtheme_child_ep_main_search_query_args', 9 );
function qtheme_child_ep_main_search_query_args( WP_Query $query ): void {
if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) {
$query->set( 'ep_is_facetable', false );
}
}
In Facets.php line 252 inspect the is_facetable method. If ep_is_facetable is false the function still returns true.
Screenshots, screen recording, code snippet
No response
Environment information
No response
WordPress and ElasticPress information
No response
Code of Conduct
Describe the bug
I’m currently implementing a custom search page using ElasticPress by overriding
search.php. In this setup, I rely onWP_Querywithep_integrate = trueto keep ElasticPress fully active for search results.However, when the “facets” feature is enabled in the ElasticPress settings, the plugin automatically adds aggregations (faceting) to the query. In my case, I need ElasticPress enabled, but I explicitly want to disable faceting for specific queries.
Problem
Looking at the implementation of
is_facetable(), the logic for theep_is_facetablequery argument is effectively treated as a positive-only override:This means that only truthy values are considered, while
falseis ignored and falls through the rest of the logic.Because of this behavior, it would be useful and more consistent to explicitly handle the case where
ep_is_facetableis set tofalse, so that faceting can be disabled at query level in a deterministic way.In particular, a condition such as:
Steps to Reproduce
Insert the following code in functions.php and enable the Filter feature from the plugin settings.
In Facets.php line 252 inspect the is_facetable method. If ep_is_facetable is false the function still returns true.
Screenshots, screen recording, code snippet
No response
Environment information
No response
WordPress and ElasticPress information
No response
Code of Conduct