Ask Your Question
1

Is there a minimum character count on a query?

asked 2010-10-12 07:08:58 -0600

Benoit gravatar image

It appears that my askbot installation does not find any term of less than 4 characters.

I'm searching for terms like pci or mpc and even though they appear in question titles and are even tags, there is still no match.

Is this intentional behavior? Is there a way to fix this?

I can see wanting to limit useless matches (esp. if partial word matches occur), but sometimes, that's what we're searching for.

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
2

answered 2010-10-13 07:16:53 -0600

Benoit gravatar image

updated 2010-10-14 20:26:42 -0600

Evgeny gravatar image

Turns out that MySQL can be tuned to do a FULLTEXT search on smaller than 4 characters. Here are the steps:

  • Edit the mysql config file (mine was /etc/my.cnf)

In the [mysqld] section, add the line:

ft_min_word_len=3

Restart mysql server and rebuild the FULLTEXT index on the answer, question and tags tables:

REPAIR TABLE answer QUICK;
REPAIR TABLE question QUICK;
REPAIR TABLE tag QUICK;

At this point, the search will return 3 letter words.

edit flag offensive delete link more

Comments

Great. I've added an option to settings. "settings"->"data entry rules"->"minimum length of search word" to support ajax search for custom minimum length search word.
Evgeny gravatar imageEvgeny ( 2010-10-14 19:05:20 -0600 )edit
Yep your instructions work, I've enabled this on askbot.org
Evgeny gravatar imageEvgeny ( 2010-10-14 19:25:07 -0600 )edit
... also you should rebuild index for table `tag`
Evgeny gravatar imageEvgeny ( 2010-10-14 19:27:16 -0600 )edit
edited your post in part to test the fixed database and actually you are using html within posts where you could more easily enter text with markdown. sorry for "breaking into" your post.
Evgeny gravatar imageEvgeny ( 2010-10-14 20:28:07 -0600 )edit
0

answered 2010-10-12 11:55:32 -0600

Evgeny gravatar image

updated 2010-10-12 15:07:49 -0600

MySQL full text search (the only option as of Oct 2010) matches for words longer than four characters.

With PostgresQL this limitation will be removed - it's a current (as of date of this answer) development item.

There is also one quirk in the full text search right now (will probably change in the future): if you type in a query that does not have any matches, but not hit enter - nothing will change on the screen. But if you hit "enter" or press the "search" button you'll get a blank list.

That is AJAX search does not yet give any feedback when no matches are found, which can leave user with an impression that it does not work.

I've done it this way to limit screen flickering when no new useful information is found. This should be somehow fixed - with maybe a phrase "nothing found yet" and shade out search results.

edit flag offensive delete link more
0

answered 2014-10-23 09:03:29 -0600

dccarson gravatar image

updated 2014-10-23 12:26:37 -0600

Of the tables mentioned in the solution, I can only find the tag table. The others have presumably been changed over time.

I decided to just repair all my tables -- what could it hurt? I used the myisamchk utility instead of running the REPAIR command in mysql. This seemed to work fine -- no errors when running the utility. However, afterward, there were at least two tables that were no longer correct: django_session and auth_permission.

Not until I ran the REPAIR command from a mysql prompt did these errors go away.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2010-10-12 07:08:58 -0600

Seen: 302 times

Last updated: Oct 23 '14