RussellHarrower
RussellHarrower

Reputation: 6820

FullText search MYSQL

so I am trying to make a simple search engine, that allows a user to search username, email, firstname and lastname.

However everytime I run the following it only returns russell.harrower instead of both russellharrower and russell.harrower

SELECT *, MATCH(username) AGAINST ('russell') as score FROMuser_infoWHERE MATCH(username) AGAINST ('russell')

I am not sure if i need to put a like status in there or what, so thought i would ask.

I want it to order the whole sql by the score.

Upvotes: 0

Views: 598

Answers (1)

patwork
patwork

Reputation: 125

Did you try using asterisk (wildcard) in boolean mode?

[...] AGAINST ('+russell*' IN BOOLEAN MODE)

http://dev.mysql.com/doc/refman/5.5/en/fulltext-boolean.html

http://www.databasejournal.com/features/mysql/article.php/1587371/Using-Fulltext-Indexes-in-MySQL---Part-2-Boolean-searches.htm

http://www.joedolson.com/boolean-query-in-mysql.php

/edit: don't use LIKE, especially with % in front of a phrase, it's veeery slow

Upvotes: 1

Related Questions