Mixed + Japanese Language Search working in Content, but not in Title, Tags …

This topic contains 2 replies, has 3 voices, and was last updated by  Kiran 5 years ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #515842

    bennyb
    Expired Member
    Post count: 19

    Dear GeoDirectory Support and community.

    We had several issues with GeoDirectory (permalink structure, fields we don’t need, user management we don’t want, structure of pages, single places design and much much more), but worked around most of them, but now we are stuck and need your help:

    We use Japanese (kanji, katakana & hiragana) + english on our site, like this i.e. this:
    Japan Shop Izumi│日本食材店 泉
    @ https://jpdir.eu

    While i understand that the “normal” search might not included tags+categories (is that correct?), the text should be searchable at least in title+content.

    When copying the (Japanese, mixed) title into the content field the search works, but the english title would be also found JUST in the title field.

    Try to find i.e. this:
    https://jpdir.eu/places/germany/hessen/frankfurt-am-main/restaurants/kamon%E3%80%80/
    like this: https://jpdir.eu/search/?geodir_search=1&stype=gd_place&s=ヌードル寿司バー&snear=&sgeo_lat=&sgeo_lon=&city=frankfurt-am-main

    Has this something to do with the indexing, or unicode support in title search?

    Just wild guesses.

    How could we fix this?

    #515881

    Alex Rollin
    Moderator
    Post count: 27815

    Hello,

    I see what you mean about searching for that value.

    Can you share WP Admin credentials so the developers can check your settings?

    #515977

    Kiran
    Moderator
    Post count: 7069

    Hi bennyb,

    – If searched string contains words then it splits string in different keywords and finds posts for each keyword.
    Ex: Searching by “Hockey Match” will retrieves all the results which contains “Hockey” or “Match” word.
    – If searched string contains single word then finds posts for whole keyword.
    Ex: Searching by “Hockey|Match” will retrieves all the results which contains “Hockey|Match” word.

    In your case posts saved with “Kamon Nudeln Sushi-Bar│カモン・ヌードル寿司バー” so it can be searched by “Kamon” or “Nudeln” or “Sushi-Bar│カモン・ヌードル寿司バー” or whole word “Kamon Nudeln Sushi-Bar│カモン・ヌードル寿司バー”.

    To meet your requirement use following PHP snippet.

    
    
    /**
     * Find out posts with title contains searched keyword.
     */
    function gd_snippet_191105_search_better_search_terms( $where, $keywords, $keyword ) {
    	global $wpdb;
    
    	if ( $keyword != '' ) {
    		$where = ' OR ( ' . $wpdb->posts . '.post_title LIKE "%' . $keyword . '%" )';
    	}
    
    	return $where;
    }
    add_filter( 'geodir_search_better_search_terms', 'gd_snippet_191105_search_better_search_terms', 20, 3 );
    
    /**
     * Find out posts with content contains searched keyword.
     */
    function gd_snippet_191105_search_content_where() {
    	global $wpdb, $s;
    
    	if ( $s != '' ) {
    		$where = ' OR ( ' . $wpdb->posts . '.post_content LIKE "%' . stripslashes( wp_specialchars_decode( $s, ENT_QUOTES ) ) . '%" )';
    	}
    
    	return $where;
    }
    add_filter( 'geodir_search_content_where', 'gd_snippet_191105_search_content_where', 20 );

    Regards,
    Kiran

Viewing 3 posts - 1 through 3 (of 3 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount