• Paul

    (@pawelszroeder)


    Hi! I’am using acf field “post_detail” in posts. I have added:

    // Custom fields weight
    add_filter( 'relevanssi_match', 'rlv_customfield_boost' );
    function rlv_customfield_boost( $match ) {
    	if ( $match->customfield > 0 ) {
    		$match->weight *= 10;
    	}
    	return $match;
    }

    And it works ok, when ACF value is without spaces etc.
    But when the custom field value is for example: Detail 1+
    then the search is loosing booster.
    How to treat such a phrase as a whole word?
    I see that in url is: ?s=detail+1%2B

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Paul

    (@pawelszroeder)

    “Boost exact matches” option does’t work. I have “detail 1+”, “detail 2+” etc. but when i search “detail 1” phrase, then detail 1 post is not on the top search results.

    Plugin Author Mikko Saari

    (@msaari)

    That filter hook works on each separate search term. For each search term that appears in a custom field, the weight is multiplied by ten.

    When the custom field value is “Detail 1+” and the search terms are “detail 1+”, this should get a multiplier of 10, because “1+” isn’t a searchable term. The “+” is removed as punctuation and “1” is too short.

    So, in this case, your problem is not in this filter; it’s that searching for “detail 1+” and “detail 2+” and “detail 3+” is always the same. All these are just searching for “detail”, with no differentiation. They all get the same results.

    Probably the best way to solve this is to adjust the punctuation control so that any plus signs that follow numbers are kept in place, and then adjusting the minimum word length to 2.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘acf field booster’ is closed to new replies.