This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Arabic words with characteristics

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Arabic words with characteristics Reply To: Arabic words with characteristics

#28775
Ernest MarcinkoErnest Marcinko
Keymaster

Hi,

By default, the WordPress database should be character case and accent insensitive. It is however possible that some of the accents may not be supported by the database collation.
Depending on the situation, I recommend 2 possible solutions:

Solution #1
If there are only a few words or phrases that exist with and without the accents, you can use the synonyms feature with the index table engine.
Entering the non-accented versions as synonyms will make it available for searches without accents.

Solution #2
This is a bit more complciated, but a far better solution, as it will probably work with all the characters in all keywords, and no need to define them one by one.

Please follow the instructions below:

1. Please add this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!

add_filter('asp_indexing_string_pre_process', 'custom_chars_asp_indexing_string_pre_process', 10, 1);
add_filter('asp_search_phrase_before_cleaning', 'custom_chars_asp_indexing_string_pre_process', 10, 1);
add_filter('asp_query_args', 'custom_chars_asp_indexing_string_pre_process', 10, 1);
function custom_chars_asp_indexing_string_pre_process($s) {
	$original = array(
		'يُ', 'ضِّ'
	);
	$replace = array(
		'ي', 'ض'
	);
	
	// Replace them
	if ( is_array($s) ) {
		if ( isset($s['s']) && !$s['_ajax_search'] ) 
			$s['s'] = str_replace($original, $replace, $s['s']);      
	} else {
		$s = str_replace($original, $replace, $s);
	}
	
	return $s;
}

2. I added only two characters for the example. Edit the $original and the $replace variables, to add the original (non characteristic) and the characterstic version of each character.
If you have a list of characteristic/non-characteristic characters, then I can help you with that.

3. Make sure to configure the index table engine. Follow the tutorial.

4. Once ready and the indexing is finished. Make sure the index table is enabled