General SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesGeneral SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 13th, 2002, 01:46 PM
johnn johnn is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: Southern California, USA
Posts: 48 johnn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
FULLTEXT search and 3-character words

Hello,
I would like to know what would you do if you're using Mysql FULLTEXT search for 3 character words? Is there a way? If no way, then what are the alternative methods do you use?

Thanks,
John

Reply With Quote
  #2  
Old December 16th, 2002, 04:04 AM
hadley hadley is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 63 hadley User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Hi John,

You've really only got two options.

Firstly, if you have access to the mysql source and can recompile it, follow the instructions at http://docsrv.caldera.com:8457/cgi-...2520Fine-tuning to build a version of mySQL that indexes whatever length words you want.

Your only other option is to manually build an index for those three letter words you're interested in. You'll need to create another table with two fields, one to contain the primary of the record you're indexing in, and the other to contain the keywords. You can then use mySQL's regular text matching to match the keywords and incorporate them into your search results.

HTH,

Hadley

Reply With Quote
  #3  
Old January 3rd, 2003, 01:10 PM
WebGuy WebGuy is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 54 WebGuy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Hadley,

How could you do option #2?

Thanks,
Corbb
__________________
Sincerely,
Corbb O'Connor, Author at DevArticles

Reply With Quote
  #4  
Old January 4th, 2003, 09:28 AM
hadley hadley is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 63 hadley User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Hi Corbb,

It's probably easiest just to show you:

Assumes you have a database called keywords, with a column for the keyword and the primary key of the thing (eg. article) it's identified with. Code is (very) rough, but you should get the general idea.

PHP Code:
<?php

function addKeywords($text$id) {
    if (
ereg("\\b\\w{3}\\b"$text$keywords)) { //match any 3 letter words
        
$keywords array_unique($keywords); //remove any duplicates
        
foreach($keywords as $keyword) {
            
$sql "INSERT INTO myKeywordTable ('id', 'keyword') VALUES ('$id', '$keyword');";
            
//append to database
        
}
    }
}

?>


You can then search this table using exact string matching (which should be reasonably fast provided you've indexed the keyword column) to find the ids of your articles.

Hadley

Reply With Quote
  #5  
Old January 4th, 2003, 10:30 PM
WebGuy WebGuy is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 54 WebGuy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Hadley,

Ah, ok.

Thanks!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesGeneral SQL Development > FULLTEXT search and 3-character words


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT