Jump to content



Welcome to AstaHost - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
Photo
- - - - -

Full Text Searches In MySQL


4 replies to this topic

#1 Fat Lotus

Fat Lotus

    Newbie [ Level 2 ]

  • Members
  • 13 posts

Posted 03 November 2006 - 02:58 AM

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!

#2 vizskywalker

vizskywalker

    Techno-Necromancer

  • Members
  • 1,018 posts
  • Location:The Net

Posted 11 November 2006 - 11:24 PM

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

#3 Hercco

Hercco

    Super Member

  • Members
  • 595 posts

Posted 23 November 2006 - 05:13 PM

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.

#4 black shadow

black shadow

    Newbie [ Level 2 ]

  • Members
  • 19 posts

Posted 25 November 2006 - 06:06 PM

I don't get it. what kind of search is this ? Search the mysql database or a tipe of search for a site /:P

#5 vizskywalker

vizskywalker

    Techno-Necromancer

  • Members
  • 1,018 posts
  • Location:The Net

Posted 26 November 2006 - 05:44 AM

This searches the MySQL database for the word ducks in the two columns specified in all the text of the column so long as the columns are of type fulltext.

~Viz



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users