SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru ripcurlksm's Avatar
    Join Date
    Aug 2004
    Location
    San Clemente, CA
    Posts
    859
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    keyword search - comma seperated values?

    1) I have a full text column that contains several paragraphs of content that I want searchable- is it better to have comma separated keywords or is it better to throw all of the text in to a full text TEXT column so it is searchable? Which is better?

    2) Currently my SQL query is not giving me the plural of keywords such as "green" as a keyword but the search for "greens" will not produce any result.

    3) Also words that appear in the database as "green dog" will not show a result if someone searched for "dog green"

    Here is my SQL query
    PHP Code:
    SELECT *
    FROM `report`
    WHERE `companyLIKE '%$P_search%' 
    OR `descriptionLIKE '%$P_search%'
    OR `market1LIKE '%$P_search%'
    OR `market2LIKE '%$P_search%'
    OR `market3LIKE '%$P_search%'
    OR `market4LIKE '%$P_search%'
    OR `market5LIKE '%$P_search%'
    OR `market6LIKE '%$P_search%'
    OR `locationLIKE '%$P_search%'
    OR `date_yearLIKE '%$P_search%'
    OR `date_monthLIKE '%$P_search%'
    OR `sourceLIKE '%$P_search%'
    OR `keywordsLIKE '%$P_search%' 

  2. #2
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    1) FULLTEXT will be faster than comma delimited fields.

    2) nothing in mysql will fix this issue in its entirety. you'll need to use something like porter stemmer to preprocess your data and your search terms.

    3) using FULLTEXT will fix this issue, too.

  3. #3
    SitePoint Guru ripcurlksm's Avatar
    Join Date
    Aug 2004
    Location
    San Clemente, CA
    Posts
    859
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    2) Thank you

    3) but I am using FULL TEXT- and my SQL statement above only returns keywords if they are in the same order they appear in the FULL TEXT column when they are stored. So if a phrase is stored as "green dog", "dog green" would not return a result. If the phrase "American Great Dane" was stored, if someone searched for American Dane, it would not return a result. Everything is workingWhat am i doing wrong?

  4. #4
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ripcurlksm View Post
    What am i doing wrong?
    LIKE does not use FULLTEXT indexes. you have to use the FULLTEXT search functions. see http://dev.mysql.com/doc/refman/5.0/...xt-search.html


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
  •