Results 1 to 6 of 6

Thread: FullTextSearching with PHP/MySQL

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    From the UK
    Posts
    422

    Unhappy FullTextSearching with PHP/MySQL

    I have what seems to be a growing problem implementing the search for my site. I was first using the basic LIKE query with MySQL and PHP but I found FullTextSearch to be more efficient in returning results.

    The problem now is that FullTextSearch has a minimum word length of 4 words - I need to set this to 3. To do this I have checked the following link http://dev.mysql.com/doc/refman/5.1/...ne-tuning.html but as you will see it needs my host to set up an option file.

    My hosts have told me they cannot update/change the option file since I am on shared server. This means I am stuck.

    Does anyone know how I can resolve this issue - I have asked this same question in the database forum but without success. I am interested in learning how other PHP/MySQL developers perform searches. I thought FullTextSearch was brilliant, but if I cannot even search for words of 3 character lengths then thats no good. There must be other ways...

    Can anyone offer any help/advice whatsoever...

  2. #2
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: FullTextSearching with PHP/MySQL

    why not just go back to using LIKE query. i dont think you will have much luck if the preset is 4.
    My usual boring signature: Something

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: FullTextSearching with PHP/MySQL

    There are other full text search engines for MySQL, e.g. Sphinx.
    If you're on shared hosting though you are out of luck. Sorry.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    From the UK
    Posts
    422

    Re: FullTextSearching with PHP/MySQL

    It looks as though I will have to return to the LIKE query...

    The reason I am using FullTextSearch in the first place is because I have a 'tags' field which has text such as 'fast red car'. If I search for 'car' then this will return that item. However if I search for 'slow car' then this item will not be returned.

    In other words I want each separate word in my query to be searched against the 'tags' (and other) field[s] to find a match... does that make sense...? FullTextSearch worked very well..

  5. #5
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: FullTextSearching with PHP/MySQL

    in that case you need a loop.
    My usual boring signature: Something

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    From the UK
    Posts
    422

    Re: FullTextSearching with PHP/MySQL

    Thanks for that - I think someone has mentioned the split function. However I'm still a little fuzzy on how to use it properly:

    if $keyword = 'small red car';

    and

    $query = SELECT * FROM item WHERE item.name = $keyword AND item.tags = $keyword...

    How do I change it to include the loop??

    I'm guessing I split the keyword by spaces - so you get $k[0] = 'small' and so on...

    But then how do I correctly search through each of these and return matches..? Do I do a search for each word in $k? I would want to return every single item which matches all of the keywords...

    The great thing about FullTextSearch is the ability to sort by relevance or score. Is there a way to mimic this with LIKE query etc?

    Thanks for the help;

Posting Permissions

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



Click Here to Expand Forum to Full Width