grandpa

Applause

what do you think the best class for searching in multi fields mysql table?

thanks
grandpa

perkiset

Perhaps I'm confused Gramps... best "class" for searching multiple fields in a table?

Pure SQL man - nothing else. There are functions like mysql_query() where you just throw your SQL into it and get a handle to a response set as a result. Maybe I'm not understanding your question..

/p

grandpa

sorry, i mean search engine class... which has nice sorting argorithm, search for a word or phrases.

like this one
http://www.

php

 classes.org/browse/package/2756.html

perkiset

The MySQL FULLTEXT indexing is pretty darn good by itself actually. It is a little weird at first to code, the syntax being a bit funky, but look here for an example:

http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html

... which is how I first

learn

 ed. Other than standard textual lookups, are you looking to do something more complicated?

/p

grandpa

i have looked at that FULLTEXT thing, and it's look damn complicated, i even dont have an idea how to convert the field type...

quote
Other than standard textual lookups, are you looking to do something more complicated?


im looking for standard textual lookups, but dont know which is the standard.... so this FULLTEXT method is the standard?

this is my 1st time build a system that required search engine thing...

do wp and smf use mysql fulltext indexing too?

many thanks perk

grandpa

wow, this is great function from mysql...
i have tried it and got nice results...

its look complicated at first but its actually really simple

problem solved  Applause

thanks x 1000000 @ perk  Applause Applause

perkiset

No worries gramps - and I agree - looks comlicated and yucky at first, but it rocks shortly thereafter.

Couple caveats I've found over the years:

* Any word that ap

pear

 s in more than 50% of your records will get tossed out of the index. Words that ap

pear

  in more than 50% of the text (or something like that) will get thrown out of <that record's> index. This is bad for small data sets, but makes sense when things start getting larger. For example, "the" will probably get thrown out and that's good because it shows up really often in each record and most probably in more than 50% of all the records in the database. The problem is if you have exactly 3 records in your table and the fields look like this:

1) cancun all inclusive vacation
2) all inclusive vacation in cancin
3) vacations in cancun

No search for ANY WORD OR PHRASE will turn up anything - ever word shows up in more than 50% of the records.

* Words of 3 or fewer letters are automatically thrown out. This ordinarily good, but not in the case of some of my retail sites. Case in point, someone comes to one of my stores and searches for "red bra." They get nothing. You can manually go and recompile it so that 3 letters words are included, but then you get a lot of and and the significance which is silly. A better anser (IMO) is to prepend the words with something that you use to "encode it" into the index... for example, I prepend zz to a list of three letter words like bra and red - the same code that converts text that gets stored in the database also converts search strings as users type them - so although they think they're search for "red" they're actually searching fort "zzred." Works like a charm.

Good luck!
/p

grandpa

yep, i tried to search "business" and got no results because all titles contain word "business"
re-read article which you gave me and found that 50% things

is there any way to give a more weight to specific field?
ex:
contain word "business" at the title will have higher value (ap

pear

  first) than word "business" at the content.

perkiset

Yeah keyword stuff your content for "business"  Applause

Other than that, I have never worked deeply with weighting the fulltext index... you're gonna haveta school me there...

/p


Perkiset's Place Home   Politics @ Perkiset's