Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 3 replies, has 0 voices.

Last updated by Bigul 1 week, 1 day ago.

Assisted by: Bigul.

Author Posts
June 2, 2025 at 7:01 am

ahmedS-9

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?

June 2, 2025 at 8:12 am
June 2, 2025 at 9:01 am #17097031

ahmedS-9

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.

June 2, 2025 at 7:12 pm #17099290

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

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.

https://wpml.org/forums/topic/when-using-elasticpress-the-translated-search-page-doesnt-show-results/

We will review it in detail and get back to you as soon as possible. Please wait.

--
Thanks!

Bigul

June 5, 2025 at 8:01 am #17108906

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

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.

https://wpml.org/forums/topic/when-using-elasticpress-the-translated-search-page-doesnt-show-results

Thank you for your understanding and patience.

--
Thanks!

Bigul