Posted on

Posts cannot be found, only one result per search

Update: This bug is no longer relevant. Versions from Premium 1.3.2 fix this and the free version has never suffered from the bug. However, I’m not sure if an update to 1.3.2 fixes this. In this case, the instructions below fix the problem.

If you’re having problems finding posts with words that appear in them and your search results tend to have exactly one hit, you’ve probably bumped into one of the more obscure Relevanssi bugs.

The problem is easy to verify: check your Relevanssi database table (_relevanssi). Sort the table by the column ‘term’ — does each word appear only once?

If so, you probably have a UNIQUE index on the column ‘term’, which causes the unfortunate result that each word can only appear once, so each query will find just one post.

Why this happens is beyond my understanding, but fortunately there’s a fix. Just remove the UNIQUE index of ‘term’ and replace it with a regular index of the type INDEX. Then just re-index the database.

If somebody can shed light on why this happens, I’d be most interested. Here’s the code that adds the index in the database:


$sql = "CREATE INDEX terms ON $relevanssi_table (term(20))";


Perhaps this causes a UNIQUE index to appear on some setups, but why – I don’t know.

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.