Gossamer Forum
Home : General : Perl Programming :

MySQL FULLTEXT

Quote Reply
MySQL FULLTEXT
Im using MySQL's FULLTEXT Index to be able to perform searches for my script. I've done:

ALTER TABLE Table1 ADD INDEX(Col1)

....and it works great for Table1, however when I do:

ALTER TABLE Table2 ADD INDEX(Col2)

....and try a search, mysql always gives:

Error: Can't find FULLTEXT index matching the column list

Anyone have any ideas?
Quote Reply
Re: [RedRum] MySQL FULLTEXT In reply to
Hi,

Those statements just add regular indexes, not fulltext indexes.

Try:

ALTER TABLE Table1 ADD FULLTEXT index_name (col1, col2, ...);

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] MySQL FULLTEXT In reply to
Thanks. I think I'd used fulltext for table1 which is why it worked then for some strange reason was trying to use INDEX instead of FULLTEXT for table2 ...doh

Last edited by:

RedRum: Dec 27, 2001, 10:25 AM
Quote Reply
Re: [Alex] MySQL FULLTEXT In reply to
fulltext searches are a little iffy....is there something better I can do?
Quote Reply
Re: [RedRum] MySQL FULLTEXT In reply to
Yeah, that's what I found too. Not much except wait for MySQL 4.1. =)

If you want good full text support, you should try MS SQL 2000. Really slick. We have it built into GT::SQL now so the forum and Links SQL can use it to do full text searches. Very fast, and nice results.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] MySQL FULLTEXT In reply to
:(

I'm trying to get my head around writing search code for my script. It's pretty tricky.

I have the searches working quite well and it's bolding the correct words when you do something like:

foo -this +that

...but I can't figure out spanning. I can create the nav bar and use limit for the search but if I do that surely search relevancy and results will be affected?

...for example if I do LIMIT 0,25 then that will mess up searches, but if I don't use it then all results will apprear on one page. I'm confused.

Last edited by:

RedRum: Dec 27, 2001, 11:15 AM
Quote Reply
Re: [RedRum] MySQL FULLTEXT In reply to
Hi,

You want to use two queries, the first to get your results, the second with just a count(*) to get the total (of course you only do the second if the first returns more then max hits).

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [RedRum] MySQL FULLTEXT In reply to
Here's an example:

http://www.perlmad.com/gallery/search.cgi

Try searching for gallery and gallery -dogs or galleries -cats

...the spanning messes up

Am I supposed to select _every_ matching link/category with the first query?


Opps gallery not galleries :)

Last edited by:

RedRum: Dec 27, 2001, 11:23 AM
Quote Reply
Re: [RedRum] MySQL FULLTEXT In reply to
The way I have done it in scripts is to do as Alex suggested. Get the totalnumber of entries with Count, then divide that with the number of link you wantper page (rounding up the number so you get whole pages). Then just use a 'for'to create the spanning HTML code.

Dont know if that was much help, but it works great in my PHP script (so thetheory should be ok Wink)

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [AndyNewby] MySQL FULLTEXT In reply to
Oh, and nice looking script BTW. Whats it gonna be; an image gallery script?

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [AndyNewby] MySQL FULLTEXT In reply to
The spanning isn't the problem. I know how to do that. Its the method of getting the search results thats the problem.

Thanks though.

Quote Reply
Re: [AndyNewby] MySQL FULLTEXT In reply to
Good guess :)

The main script is here:

http://www.perlmad.com/gallery/img.cgi

I've been busting my ass on it :)
Quote Reply
Re: [RedRum] MySQL FULLTEXT In reply to
Wow, nice. Good job (nice design too Wink). This gonnabe one of the scripts you sell at your site?


Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!

Last edited by:

AndyNewby: Dec 27, 2001, 11:41 AM
Quote Reply
Re: [AndyNewby] MySQL FULLTEXT In reply to
>>This gonnabe one of the scripts you sell at your site?<<

Not sure what I'm gonna do.

Damn I keep finding irritating bugs....just found one that seems to log you in when you go to the signup error page even though authentication is done with cookies. Grrr....

Im pleased with my template parser too...I've added more features so you can do things like...

<%* x length VAR%>

...and it will print * x number of times. Good for passwords and stuff as I can have a tag like

<%password%>

and hide it with...

<%* x length password%>

Last edited by:

RedRum: Dec 27, 2001, 11:44 AM
Quote Reply
Re: [RedRum] MySQL FULLTEXT In reply to
If interested, here is the code for that little tag example above...

Code:
$parsed =~ s,<%\s*([^\s]+)\s*x\s*(length)?\s*(\w+)\s*%>,

if ($2) {
$1 x length $tags->{$3}
}
else {
$1 x $3
}
,oesg;

...so it will either accept <%char x number%> or <%char x tag%>..eg...

<%= x 75%> or <%* x length password%>

....anyway Im waffling Im sure you get the drift.



Last edited by:

RedRum: Dec 27, 2001, 11:50 AM
Quote Reply
Re: [AndyNewby] MySQL FULLTEXT In reply to
Ooo I fixed those bugs above. Its was form fields screwing up the authentication when going through the parser as they had the same names.
Quote Reply
Re: [Alex] MySQL FULLTEXT In reply to
Ahh finally got it working with a COUNT(*), thanks :)

...Search.pm is pretty congested Laugh
Quote Reply
Re: [RedRum] MySQL FULLTEXT In reply to
Quote:
Ahh finally got it working with a COUNT(*), thanks :)

So who's the cute blonde with the nice headlights in all those 3k jpegs named like this - XBs96rXdJm.jpe

easy does it
Quote Reply
Re: [Bearwithme] MySQL FULLTEXT In reply to
Hmm guess I shoulda removed those first huh :)

I'm hoping to sell it to adult webmasters who run thumbnail galleries so grabbed the first thumbnail I found and added it loads of times to see how it looked as well as to check page spanning Blush

Ya shouldn't be snooping through my directories in any case :)

...as for the weird file names, I'm generating a random name to stop overwriting

Blocked ya all :)


Last edited by:

RedRum: Dec 27, 2001, 2:14 PM
Quote Reply
Re: [Alex] MySQL FULLTEXT In reply to
Hi,

Is there a way to search substrings with FULLTEXT searches?

At the moment if I search for cat I get no results but cats gives one result.

Thanks.

Last edited by:

RedRum: Dec 28, 2001, 5:23 AM