Continue reading Restricting the search for non-logged-in users

Restricting the search for non-logged-in users

There was an interesting support question: I have website with logged-in users as well as non-logged-in users. The logged-in user should be able to search through everything on the website, but the non-logged-in users should only be able to search the user profiles. Is it at all possible to differentiate the searches like this? The…

Read more Restricting the search for non-logged-in users 3 Comments on Restricting the search for non-logged-in users
Continue reading Blocking pre and code tags

Blocking pre and code tags

If your posts have lots of programming code examples in <pre> and <code> tags, those might look pretty bad in the search results. A snippet of programming code isn’t usually a good excerpt, and if you use those tags purely for code snippets, they won’t likely contain significant search content, either. Fortunately it’s easy to…

Read more Blocking pre and code tags 0 Comment on Blocking pre and code tags
Continue reading Using AND and NOT for Boolean operators

Using AND and NOT for Boolean operators

Relevanssi Premium has support for in-query Boolean operators. Relevanssi uses + and – for the operators: cats -dogs and cats +kittens. If you prefer instead to use the verbal AND and NOT operators, it only takes one small function. Add this to your site: This function (on the relevanssi_search_filters hook) looks at the search query…

Read more Using AND and NOT for Boolean operators 6 Comments on Using AND and NOT for Boolean operators
Continue reading Controlling attachment types in index

Controlling attachment types in index

Relevanssi lets you index attachments. But perhaps you only want to index a particular type of attachment? Relevanssi settings don’t have any control over that, it’s either all attachments or nothing. It is possible to choose which kinds of attachments are indexed. It is done with the relevanssi_indexing_restriction filter hook, which lets you control which…

Read more Controlling attachment types in index 16 Comments on Controlling attachment types in index
Continue reading Restricting the indexing to particular user roles

Restricting the indexing to particular user roles

From the Relevanssi settings, you can only choose whether subscribers are indexed or not. If you need finer control over what user roles are indexed by Relevanssi, you can use the relevanssi_user_index_ok filter hook with the following code. Place it in your theme functions.php: Just adjust the $block_these_roles array to include the roles you want…

Read more Restricting the indexing to particular user roles 0 Comment on Restricting the indexing to particular user roles
Continue reading Adding extra boost for exact title matches

Adding extra boost for exact title matches

Every now and then, somebody wants to see exact title matches higher in the results. Usually, the best way to do this is to increase the title weight, maybe switch the default operator to AND and let the Relevanssi algorithm lift the best results. If that is not enough, you can use this code to…

Read more Adding extra boost for exact title matches 13 Comments on Adding extra boost for exact title matches
Continue reading Restricting Did you mean suggestions to one post type

Restricting Did you mean suggestions to one post type

Sometimes it may be necessary to restrict the Did you mean suggestions Relevanssi serves to just one post type. There’s no option for that, as by default the Relevanssi database the Did you mean suggestions use as a source (this only applies to Premium, that is) doesn’t have any information about the post types the…

Read more Restricting Did you mean suggestions to one post type 0 Comment on Restricting Did you mean suggestions to one post type
Continue reading Auto-redirecting with one search result

Auto-redirecting with one search result

If you want to auto-direct the user directly to the result if there’s just one result for the search, that’s quite easy. Add the following code to your site: This is not Relevanssi-specific and works just fine even without Relevanssi. If you are using Relevanssi on a multisite system, you need a small change to…

Read more Auto-redirecting with one search result 15 Comments on Auto-redirecting with one search result
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