FULLTEXT search engine...need help??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dazz1
Forum Newbie
Posts: 8
Joined: Wed May 14, 2003 8:45 pm

FULLTEXT search engine...need help??

Post by dazz1 »

I use the PHP search engine at http://www.designplace.org/ It works 100% exept for that it's not fulltext, and the results come out not the way I want so i want it to be FULLTEXT, my DB is set to be FULLTEXT and everything, I've read through every sites and throught the mysql tutorial for FULLTEXT, but i cannot get this to work, maybe its the way the script is setup or something

PLLEASEE help me!!!

thanks!!!!!!!!!!!!!
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

First thing I noticed is that the script uses GET as the form method - POST is much better.

You mentioned a mysql FULLTEXT tutorial: do you mean the mysql manual? See mysql.com if you don't have it - downloadable version is worth getting. There's really not much I could add to the manual notes. Have you got mysql 3.23.23 or higher? (previous versions don't support FULLTEXT searches).

Post your mysql query string if you're still stuck.

One other point: mysql 4.01 added support for the BOOLEAN option with FULLTEXT searches. In my opinion, MATCH is pretty useless without it.

A non-boolean MATCH search cannot do a whole phrase search: it will (afaik) rank results depending on the frequency of the individual words in the phrase regardless of whether they actually occur as a phrase or not (and also seems to rank the results depending on how many other words there are to "dilute" the search terms).

However, to my mind, a site search script isn't much use if you can't do a meaningful whole phrase search so if you don't have mysql 4.01 or higher I'd recommend you don't use FULLTEXT searches.

Of course site search scripts aren't much use without ranking either - could get around that with a bit of substr_count in the script.

Experiment yourself though, and see what you think.
dazz1
Forum Newbie
Posts: 8
Joined: Wed May 14, 2003 8:45 pm

Post by dazz1 »

hmm thanks for saying that
i got mysql 3.23.47

i really need fulltext cause my database has stuff like for 'example'

apple.juice
or
apple_juice

when somone searches for apple juicenone of those matches come up

can you give me an example of the best query string to use for fulltext

i have 1 table and 3 fields id url and contains

the search,searches the contains field

(my site is a huge db of websites)
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

I don't know what FULLTEXT indexes you have defined but here's a sample which might help:

Code: Select all

<?php
$mysql = "SELECT column1,column2, MATCH (column3) AGAINST ('search text') AS score FROM table WHERE MATCH (column3) AGAINST ('search text')";
$query = mysql_query($mysql) or die("Cannot query the database.<br>" . mysql_error());

echo mysql_num_rows($query);
echo '<hr>';
while ($result = mysql_fetch_assoc($query)) {

    print_r($result);
    echo '<hr>';

}
?>
Column3 is the column you are searching in: this must have a FULLTEXT index. Cols 1 & 2 are the columns returned in the result array - along with "score" (you can display the relevance alongside the search results by echo'ing out $result['score'] in the while loop).
Last edited by McGruff on Thu Aug 11, 2005 9:22 am, edited 1 time in total.
dazz1
Forum Newbie
Posts: 8
Joined: Wed May 14, 2003 8:45 pm

Post by dazz1 »

hmm, this not working, i do the search but i always get no results now, thats what different

Is thier a free script which is a small MYSQL FULLTEXT search php script on a site or something i could use instead???
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Above script should work for you - it tested OK on my local server. Did you define a FULLTEXT index?

Sorry don't know any free scripts for this.
dazz1
Forum Newbie
Posts: 8
Joined: Wed May 14, 2003 8:45 pm

Post by dazz1 »

ok, i got it working, i think, FULLTEXT isntwhat i thought it was, whatever, thanks for the help
Post Reply