SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru
    Join Date
    Nov 2008
    Posts
    622
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    fulltext search results

    hi all

    i m using this below code to search fulltext

    PHP Code:
    $sql "SELECT product_name FROM product_table WHERE MATCH (product_name) AGAINST ('+".$item_name."' IN BOOLEAN MODE)";
    $resultmysql_query($sql);
            while(
    $row=mysql_fetch_array($result))
            {
                echo 
    $row['product_name']."\n";
                
            } 
    Product name is
    Code:
    New Nokia 5800 Red
    If i write "Nokia" in search box then this product name is shown.

    If i write "5800" in search box then also this product name is shown.

    But if i write 'Nokia 5800" in search box then this product name is not shown.

    vineet

  2. #2
    SitePoint Member
    Join Date
    Jan 2012
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can't replicate your findings. However, " +'Nokia 5800' " means " find rows that contain the word 'Nokia', but rank rows higher if they also contain '5800' "

    To find an exact phrase, you'd need to wrap the phrase in qutoation marks - which might look like this...

    Code:
    $sql = "SELECT product_name,MATCH (product_name) AGAINST ('+\"".$item_name."\"' IN BOOLEAN MODE) score FROM product_table ";
    Note that I've rewritten the query so you can see the actual score returned by each result!


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
  •