Continue reading Different fuzzy search setting on different searches

Different fuzzy search setting on different searches

On one of our sites we have 2 search boxes, one where you can do a normal search and the other where you can search for employees or departments. The employees/department search is done by using the relevanssi_do_query() function. Can we use fuzzy matching on the normal search and disable it on the employees/department search?…

Read more Different fuzzy search setting on different searches 0 Comment on Different fuzzy search setting on different searches
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 Using Relevanssi without a search term

Using Relevanssi without a search term

Version 1.7.3 introduces the possibility to use Relevanssi without a search term. This is useful when you have extra query arguments that can be used to narrow the search, but which would be useful without a search term present. This was originally implented for a restaurant search, where the users can search for restaurants based…

Read more Using Relevanssi without a search term 42 Comments on Using Relevanssi without a search term
Continue reading Separating posts by post type

Separating posts by post type

Using the relevanssi_hits_filter, it’s easy to separate the search results by post type. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 add_filter(’relevanssi_hits_filter’, ‘separate_result_types’); function separate_result_types($hits) { $types = array(); $types[’mycustomtypethatgoesfirst’] = array(); $types[’thesecondmostimportanttype’] = array(); $types[’post’] = array(); $types[’page’] = array();   //…

Read more Separating posts by post type 28 Comments on Separating posts by post type
Continue reading Relevanssi_post_ok filter

Relevanssi_post_ok filter

Versions 2.9.8 (free) and 1.5.13 (premium) added a new filter, relevanssi_post_ok, which can be used to add support for membership plugins where there is a need to restrict certain posts from certain users. By default, this filter calls relevanssi_default_post_ok(), which has built-in support for private posts, Role-Scoper and s2member. Add your own function, if you…

Read more Relevanssi_post_ok filter 3 Comments on Relevanssi_post_ok filter
Continue reading Modify excerpts with relevanssi_excerpt_content

Modify excerpts with relevanssi_excerpt_content

From free 2.9.1 and Premium 1.5.8, there’s a new filter that makes modifying the excerpts easier. The relevanssi_excerpt_content filter is run after the post content is run through the the_content filter and before any other cleanup is done. This is a good point to insert for example custom field content. The filter hook passes three…

Read more Modify excerpts with relevanssi_excerpt_content 33 Comments on Modify excerpts with relevanssi_excerpt_content
Continue reading Disabling title or content indexing

Disabling title or content indexing

If you want to prevent the indexing titles or post content for some reason, Premium has couple of useful filters starting from version 1.5.5. The filters are called┬árelevanssi_index_content and┬árelevanssi_index_titles. These are simple true/false filters, so if you want to activate the filter, add a function that returns false, like this: add_filter(‘relevanssi_index_content’, ‘contentoff’); function contentoff() {…

Read more Disabling title or content indexing 56 Comments on Disabling title or content indexing
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 Taxonomy page search

Taxonomy page search

To include taxonomy pages (categories, tags, custom taxonomies) in the search, enable the option in the options page. There’s also the option to choose which taxonomies are included. By default everything is indexed. Currently the title of the taxonomy is indexed with the description field. Indexing other fields isn’t currently possible. Taxonomy pages should be…

Read more Taxonomy page search 33 Comments on Taxonomy page search
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