FacetWP does not fully integrate with the ElasticPress plugin. We have not extensively tested ElasticPress with FacetWP ourselves, but some users have been able to get it working with Search facets specifically. But it does not work with other facet types which still require MySQL (the WordPress database) in order to function properly.

If you are using ElasticPress with a Search facet, or on a search archive page, ElasticPress will return error 400 responses with the message “No mapping found for [post__in] in order to sort on”.

The problem happens when a default sort order is used, and no custom orderby query parameter is specified. In that case, FacetWP by default orders results by relevancy, by setting the orderby parameter to post__in.

ElasticPress cannot sort results in a given order passed by an array of arguments (like the IDs in post__in) but calculates a matching score against a single argument for all the results possible.

The workaround to get FacetWP working with ElasticPress is to customize the query and set the orderby query parameter to something else than post__in, or to disable ordering by relevancy with the following code:

add_filter( 'facetwp_use_search_relevancy', '__return_false' );

Fix the 10.000 result limit

Be aware that Elasticpress limits results to 10.000 for performance reasons, so FacetWP will also not index or show more than 10.000 results.

You can have the actual total number being returned by adding the following snippet to your (child) theme’s functions.php:

    function( $formatted_args ) {
        $formatted_args['track_total_hits'] = true;
        return $formatted_args;

See also