Jump to content
xisto Community
Fat Lotus

Full Text Searches In MySQL

Recommended Posts

Before I begin, you must remember that the columns that you will be searching in must be a fulltext index

 

Let's start with the basics:

 

Just the relavant results:

(Searching for "Ducks"):

SELECT * FROM [i]tablename[/i] WHERE MATCH([i]coloumnname[/i],[i]columnname2[/i]) AGAINST ('Ducks');

But that just won't work. Will it? Let's try again, this time ordering by the relavancy.

SELECT * FROM [i]tablename[/i] WHERE MATCH([i]coloumnname[/i],[i]columnname2[/i]) AGAINST ('Ducks') ORDER BY MATCH([i]columnname[/i],[i]columnname2[/i]) AGAINST ('Ducks');

That's better!

Share this post


Link to post
Share on other sites

I'm a little unclear as to the difference that the

ORDER BY MATCH(columnname, columnname2) AGAINST('Ducks')
makes to the query.

First, if I understand this correctly, this query searches two columns, columnname and columnname2 for Ducks, for which they must be full text.

So does this order the results by appearance order in the database? And does the second part change it to order by how closely it matches Ducks? And how many times it matches Ducks?

~Viz

Share this post


Link to post
Share on other sites

It matches 'Ducks' infitite number of times and the results are sorted by relevance. Someone else has to help here with the order direction, is it decreasing relevance or increasing? Anyways basically this means that if you have a full text field with the word 'Ducks' appearing twice, it is of higher relevance than fields with only one occurance.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.