Continue reading Partial matches to just one custom field

Partial matches to just one custom field

Is it possible to set (with filters and/or actions/functions) Relevanssi to use whole words keyword matching for post titles and 2 custom fields, and partial keyword matching only for a specific custom field (sku in this case)? Indeed it is! That is, you can’t set different keyword matching methods to different parts of the post,…

Read more Partial matches to just one custom field 0 Comment on Partial matches to just one custom field
Continue reading Private custom fields

Private custom fields

I use private custom fields. I want to index them in the administration but not on the public site. How to do ? Initially this seems impossible to do with Relevanssi, but it’s possible. Doing this requires Relevanssi Premium. The free version doesn’t know which custom field matches the search term, it just knows some custom…

Read more Private custom fields 0 Comment on Private custom fields
Continue reading Adding extra weight to AND results in an OR search

Adding extra weight to AND results in an OR search

My Relevanssi engine has the AND operator enabled, with a fallback to OR when the search finds no matches. I’d like the search to display first the AND results and later the OR results. For example, if I search for “wedding party”, I’d like the search to show first the entries matching both words and…

Read more Adding extra weight to AND results in an OR search 0 Comment on Adding extra weight to AND results in an OR search
Continue reading Which custom fields had the hit?

Which custom fields had the hit?

While the free version of Relevanssi will match search terms in custom field content, it doesn’t know which custom field had the matching content. Premium has that information and it can be made available. First, you need this in your functions.php: add_filter(’relevanssi_match’, ‘cfdetail’); function cfdetail($match) { global $customfield_data; $customfield_data[$match->doc] = $match->customfield_detail; return $match; }add_filter(‘relevanssi_match’, ‘cfdetail’);…

Read more Which custom fields had the hit? 10 Comments on Which custom fields had the hit?
Continue reading Making post body not count

Making post body not count

This function will re-calculate the post weights so that post body has no significance. Only titles, excerpts, categories and so on will effect the search results. add_filter(‘relevanssi_match’, ‘no_post_body’); function no_post_body($match) { $title_boost = get_option(‘relevanssi_title_boost’); $tag_boost = get_option(‘relevanssi_tag_boost’); $link_boost = get_option(‘relevanssi_link_boost’); $comment_boost = get_option(‘relevanssi_comment_boost’); $idf = $match->weight / $match->tf; $match->tf = $match->title * $title_boost + $match->comment…

Read more Making post body not count 0 Comment on Making post body not count
Continue reading Custom weighing with relevanssi_match hook

Custom weighing with relevanssi_match hook

If you want to fine-tune the post weights, version 1.4.5 introduces a new hook for that. The relevanssi_match hook lets you modify the matches found for queries. It passes a match object, which has the post id ($match->doc), number of hits found in different parts of the post and the weight assigned to the post…

Read more Custom weighing with relevanssi_match hook 60 Comments on Custom weighing with relevanssi_match hook