• Resolved kungfuclass

    (@kungfuclass)


    Dear Sir,

    We searched about this topic on your forum and found a previous answer.
    We followed your suggestions to add some codes to the functions.php and rebuilt the index in the Relevanssi plugin. However, the wordpress default search box can only recognize the data in the first column of the Ninja Table. When I search for the data of the other columns, the wordpress default search box does not show.

    Please kindly advise how to amend the following code:

    /*relevanssi*/
    add_filter( 'relevanssi_post_content', 'relevanssi_index_ninja_cached_table_html' );
    
    function relevanssi_index_ninja_cached_table_html( $content ) {
    	$m = preg_match_all(
    		'/.*\[ninja_tables.*?id=["\'](\d+)["\'].*?\]/im',
    		$content,
    		$matches,
    		PREG_PATTERN_ORDER
    	);
    	if ( ! $m ) {
    		return $content;
    	}
    	foreach ( $matches[1] as $table_id ) {
    		$cached_table_html = get_post_meta( $table_id, '__ninja_cached_table_html', true );
    		$content .= ' ' . $cached_table_html;
    	}
    
    	return $content;
    }

    Thanks & regards,
    KF

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Mikko Saari

    (@msaari)

    The function gets all the content from the __ninja_cached_table_html custom field for the table post. That should contain the full table HTML. Does it? Check what the custom field contains. At least some content in other columns works, searching for “星期二” or “愉景灣愉景廣場” does find the post. What are you searching for that cannot be found?

    Note that Relevanssi doesn’t work well in Chinese. Using phpjieba helps somewhat, without it the results are almost random. See instructions here: https://www.relevanssi.com/knowledge-base/relevanssi-and-languages/

    If you can’t use phpjieba, at least set the minimum word length to “2” in the advanced indexing settings, set the matching to partial matching and enable the inside-word matching:

    add_filter( 'relevanssi_fuzzy_query', 'rlv_partial_inside_words' );
    function rlv_partial_inside_words( $query ) {
    	return "(term LIKE '%#term#%')";
    }

    But in general Relevanssi is not a particularly good tool for searching Chinese, Japanese or Korean text.

    Thread Starter kungfuclass

    (@kungfuclass)

    Dear Mikko,

    Your code helps!! Thank you for your super quick response!
    You are a hero!!

    Thanks & regards,
    KF

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘WordPress Default Search cannot show data in Ninja Table’ is closed to new replies.