Troubleshooting

Why doesn't my search function work?

Scenario:
"I'm testing out the search function on my site and it doesn't turn up with any results, even though I know I've posted items with those keywords."

Solution:
Unfortunately, this is not a Nucleus error, but a MySQL issue that occurs with search when there aren't many records. Your only solution is to post more items.

Original forum thread (thanks, xiffy!):
http://forum.nucleuscms.org/viewtopic.php?t=5679

Further explanation:
There are a few things to consider and it all comes back to the MySQL engine and the way we use the indices.

First of all, we use the fulltext functionality of indexes which makes it possible to combine keywords, etc. This is good. The bad thing is that MySQL uses a 50% relevance threshold. This is best explained by an example. Consider you have two mini postings:

Title: First item.
Body: This is my first item

Title: Second item
Body: This is my second item.

Suppose we want to find posts with the keyword 'item'. You would expect to get two results, but you get zero. This is because the word 'item' occurs in more then 50% of all posts, making it an irrelevant search word for MySQL. So with only these two items in your weblog, all searches will render zero results, because all words occur in 50% of your items.

Now suppose we add a third item:

Title: Third item
Body: This is my third item

Again, searching for 'item' will give you zero results as it still occurs in 50% or more items. However, searching for the word 'third' should give one result, the last item.

When you gradually fill your database, the chances of relevant words occuring in 50% or more of your items slowly shrink, making the search engine better and better. It's awkward but true. This search engine is not designed for blogs with 10 items or less, it's built for 100 items and more.

section: Troubleshooting | submitted by Leng on 2005.Sep.18 | 3314 views

item rate
Total votes: 17 - Rating: 9.65

Please tell us how useful this answer was to you (0 = useless, 10 = very very helpful):

10