If you are using ElasticPress with a Search facet or with facets 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' );

See also