Ask Your Question
1

Is there a minimum character count on a query?

asked Oct 12 '10

Benoit gravatar image Benoit flag of United States
825 6 24

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.

2 Answers

Sort by ยป oldest newest most voted
2
Benoit has selected this answer as correct

answered Oct 13 '10

Benoit gravatar image Benoit flag of United States
825 6 24

updated Oct 14 '10

Evgeny gravatar image Evgeny flag of Chile
6665 31 49 95
http://askbot.org/

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.

link

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 (Oct 14 '10)
Yep your instructions work, I've enabled this on askbot.orgEvgeny (Oct 14 '10)
... also you should rebuild index for table `tag` Evgeny (Oct 14 '10)
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 (Oct 14 '10)
0
Benoit has selected this answer as correct

answered Oct 12 '10

Evgeny gravatar image Evgeny flag of Chile
6665 31 49 95
http://askbot.org/

updated Oct 12 '10

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.

link

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
[hide preview]

Question tools

Follow
1 follower

subscribe to rss feed

Stats

Asked: Oct 12 '10

Seen: 57 times

Last updated: Oct 14 '10