If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > help with full-text search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-21-09, 03:44
julj julj is offline
Registered User
 
Join Date: May 2009
Posts: 2
help with full-text search

hi,

I want to perform full-text search in the tables shown below.
What I would like is to search for restaurants rows having all or some of the search strings in any fields or the comments.

eg: "japanese cheap amazing barcelona"

I don't know how to perform a full text search, knowing that some of the columns are ID (e.g. city_id) with name stored in separate tables and that the comments are in a separate table.

Any help or pointers?

Thanks


mysql>describe restaurants;
+---------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| name | varchar(50) | YES | | NULL | |
| street_number | int(11) | YES | | NULL | |
| street | varchar(50) | YES | | NULL | |
| postal_code | varchar(8) | YES | | NULL | |
| city_id | int(11) | YES | | NULL | |
| country_id | int(11) | YES | | NULL | |
| link | varchar(80) | YES | | NULL | |
| opening_hours | varchar(80) | YES | | NULL | |
| price_range | int(11) | YES | | NULL | |
| type_id | int(11) | YES | | NULL | |
+---------------+------------------+------+-----+---------+----------------+


mysql> describe comments;
+----------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| user_id | int(10) unsigned | NO | | NULL | |
| resto_id | int(10) unsigned | NO | | NULL | |
| comment | varchar(500) | YES | | NULL | |
+----------+------------------+------+-----+---------+----------------+
Reply With Quote
  #2 (permalink)  
Old 05-21-09, 07:03
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
you'll need a FULLTEXT index on each table

there's lots more good information in da manual -- you need to read it
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 05-21-09, 10:00
julj julj is offline
Registered User
 
Join Date: May 2009
Posts: 2
Thanks, but my question is more about how to perform the search across the different tables (I know I must add indexes).

More explicitely, I want to find the restaurants having:
-all or some of the search strings in any text fields (text, varchar...) of the 'restaurants' table
-'city_id' and/or 'country_id' corresponding to cities or countries name matching some of the search strings
-their ids in rows of the 'comments' table which 'comment' field contain some of the search strings.
Reply With Quote
  #4 (permalink)  
Old 05-21-09, 10:59
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
Originally Posted by julj
Any help or pointers?
sure

- don't use fulltext searching on VARCHAR columns if LIKE is more appropriate
- consider searching individual tables separately instead of as part of a join
- don't search numeric columns
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On