SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: AGAINST syntax

  1. #1
    SitePoint Wizard silver trophy redemption's Avatar
    Join Date
    Sep 2001
    Location
    Singapore
    Posts
    5,269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    AGAINST syntax

    Code:
    SELECT * FROM Products
    WHERE MATCH (Title,Description) AGAINST ('keyword1 keyword2')
    the recent SitePoint Tech Times had a great tip on FULLTEXT searching but i've a problem implementing it...
    can someone explain how the AGAINST syntax works... the article says you can use more that one word say 'keyword1 keyword2' but will this look for a match of 'keyword1 keyword2' or 'keyword1' AND 'keyword2'...

    thanks... i tried searching in the MySQL docs but no luck...

  2. #2
    SitePoint Wizard silver trophy redemption's Avatar
    Join Date
    Sep 2001
    Location
    Singapore
    Posts
    5,269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry for the bump but i needed an answer...

    anyone?

  3. #3
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you alter the table to add fulltext search?

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  4. #4
    SitePoint Addict Philip Toews's Avatar
    Join Date
    Dec 2001
    Location
    Kuala Belait, Brunei
    Posts
    367
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Add the fulltext index for sure...but

    You definately need to add the fulltext index for that kind of query to work. I have a related question however. Do you need to rebuild that index every time you insert a record into the DB or will MySQL take care of that automatically once the FULLTEXT index has been created?

    p

    p.s. sorry for borrowing the thread. You may also want to consider the "score" value that you can get out of this MySQL feature. MySQL will return relevancy numbers for each row...so you can rank your search results. The manual has a great example

    here
    Philip Toews Professional esl Educator and ASP.NET wannabe

    http://www.philiptoews.com
    philip@philiptoews.com

  5. #5
    SitePoint Wizard silver trophy redemption's Avatar
    Join Date
    Sep 2001
    Location
    Singapore
    Posts
    5,269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    seanf: yes i've added the FULLTEXT index...

    Philip: no problem, we're in this together
    as for your question, you do not need to rebuild the FULLTEXT index... it's done automatically for you... it's be a bother otherwise wouldn't it

    i still need an answer to my question though... i'd be very grateful to anyone who can help

  6. #6
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is the page you want in the manual:
    http://www.mysql.com/doc/F/u/Fulltext_Search.html

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  7. #7
    SitePoint Wizard silver trophy redemption's Avatar
    Join Date
    Sep 2001
    Location
    Singapore
    Posts
    5,269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks seanf but i've read that page before i posted...

    i need to know when you use more that one word say 'keyword1 keyword2' but will this look for a match of 'keyword1 keyword2' or 'keyword1' AND 'keyword2'...

    or if i missed it in the manual please point out my mistake


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •