The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 22, 2019, 11:46:52 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: php >< mysql search class  (Read 4586 times)
grandpa
Rookie
**
Offline Offline

Posts: 20



View Profile
« on: July 17, 2007, 07:11:30 AM »

 Need Help

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

thanks
grandpa
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #1 on: July 17, 2007, 10:11:16 AM »

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
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
grandpa
Rookie
**
Offline Offline

Posts: 20



View Profile
« Reply #2 on: July 18, 2007, 04:29:04 AM »

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

like this one
http://www.phpclasses.org/browse/package/2756.html
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #3 on: July 18, 2007, 08:41:33 AM »

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 learned. Other than standard textual lookups, are you looking to do something more complicated?

/p
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
grandpa
Rookie
**
Offline Offline

Posts: 20



View Profile
« Reply #4 on: July 18, 2007, 10:10:06 AM »

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
Logged
grandpa
Rookie
**
Offline Offline

Posts: 20



View Profile
« Reply #5 on: July 18, 2007, 12:22:38 PM »

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 

thanks x 1000000 @ perk  Praise Praise
« Last Edit: July 18, 2007, 12:26:01 PM by grandpa » Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #6 on: July 18, 2007, 12:53:37 PM »

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 appears in more than 50% of your records will get tossed out of the index. Words that appear 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
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
grandpa
Rookie
**
Offline Offline

Posts: 20



View Profile
« Reply #7 on: July 18, 2007, 01:17:33 PM »

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 (appear first) than word "business" at the content.
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #8 on: July 18, 2007, 01:21:35 PM »

Yeah keyword stuff your content for "business"  ROFLMAO

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

/p
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!