Background of the issue:
I am attempting to configure ElasticPress to direct Arabic-language searches to the appropriate Arabic index, ensuring that the post_lang parameter is correctly set to ar. I expected Arabic searches to query the Arabic index in ElasticPress and return relevant results based on post_lang: ar, just as English searches correctly query the English index. I have applied the recommended ep_formatted_args filter to include the correct post_lang.raw. Here is the code I used: add_filter( 'ep_formatted_args', 'add_wpml_language_to_ep_query', 10, 2 ); function add_wpml_language_to_ep_query( $formatted_args, $args ) { if ( function_exists( 'apply_filters' ) ) { $current_lang = apply_filters( 'wpml_current_language', null ); if ( $current_lang ) { $formatted_args['query']['bool']['must'][] = [ 'term' => [ 'post_lang.raw' => $current_lang ] ]; } } return $formatted_args; }
Symptoms:
Despite applying the recommended ep_formatted_args filter, Arabic searches still fail. All search queries—regardless of the current language—are routed to the English index (...-post-1), and Arabic queries return no results. Additionally, we're encountering a malformed query error when the language condition is injected via the filter. The query appears to break when the post_lang.raw clause is added.
Questions:
Could you please connect me with Bigul, as he may have insights into this matter?
Just following up to provide more context from our earlier chat — the issue was previously handled by Bigul, who provided the ep_formatted_args filter code. We're currently trying to improve that solution because Arabic searches are still failing, and the query appears to break when post_lang.raw is added.
You now have access to the query logs via the credentials I submitted earlier through the private form. Please check the ElasticPress query logs to see the specific error we’re facing after applying the filter code.
If you need anything else tested or reproduced, I can do that on my side and send the results.
Looking forward to your guidance on resolving or refining the current filter setup.
As discussed in our chat last week, this issue is related to the ticket referenced below. It has already been escalated to our team for further investigation.
We are closing this ticket as it is a duplicate of the following one, which has already been escalated to our second-tier team for further investigation. We will continue debugging and provide updates through the original ticket.