Posted on

Spam search blocking

Spam searches are a common feature on WordPress sites. Spam bots make lots of useless queries, in the hopes of having sites display the search queries somewhere, providing links to spam sites. This is unpleasant, clogs up the search logs and wastes resources.

Relevanssi Premium introduced a new spam blocking feature in version 2.15.0. This tool can be used to block spam queries from polluting your search logs and wasting your server resources. Ideally the spam would be blocked on server level before it even has a chance to start up WordPress, but that’s often harder to do, so at least this provides some level of protection against search spam.

The Relevanssi spam blocking is based on keywords: you need to enter keywords in the spam block settings and if those keywords appear anywhere in the search query, the query process is immediately stopped and nothing else will happen. You can also block all queries that contain Chinese or Cyrillic characters, or emoji.

Be careful: there’s no record made of the blocked queries, no logs or anything, to avoid spending any resources on these queries. It’s possible to break your search for legitimate users with this feature.

How to use the spam blocking

You can find the spam blocking feature on the Relevanssi settings page under the “Spam Block” tab. If you can’t see the tab, make sure you’re running Relevanssi Premium with version 2.15.0 or higher.

To get an idea of suitable keywords to block, check the Dashboard > User searches. If you’re not seeing anything there, enable logging in Relevanssi settings (but if you’re reading this, you likely have logging enabled and have noticed the spam queries in the logs).

As mentioned on the settings page, top level domains are usually very good block terms: they appear often in spam queries, but very rarely in actual searches, especially if you include the dot in it: .com, .cn, .shop, .online – these are rare in real searches, but commonplace in spam.

What if you don’t have Premium?

Well, you should obviously buy Premium (it has lots of other cool features)! If you can’t, or just want to do some keyword blocking, you can also do it in code without Premium. See Keyword-based search blocking.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.