MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 3rd, 2009, 11:36 AM
honda259 honda259 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2009
Posts: 3 honda259 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 47 m 16 sec
Reputation Power: 0
Fulltext Search gives too many results

Hi, Im new to the forum, I had a search to see if anyone had already answered my question but couldnt find anything.

Im trying to write a simple search engine using a ProductName column to search on.

Example Data

Column pdt_name:
widget
megawidget
nice widget
blue widget



Here is my query,

SELECT pdt_name, MATCH(pdt_name)
AGAINST ('+widget +blue') as Relevance
FROM products WHERE MATCH
(pdt_name) AGAINST('+widget +blue'
IN BOOLEAN MODE)
HAVING Relevance > 0.2 ORDER
BY Relevance DESC;


The problem is, it is returning too many results. If I search on "Blue Widget" I only want one result, it is instead bringing back many results albeit with a relevance score, although this score does not give me an obvious cut off number, eg those below 5 are no good.


Any advice will be greatly appreciated.

Reply With Quote
  #2  
Old July 3rd, 2009, 11:49 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 20,687 r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 1 Week 3 Days 9 h 27 m 54 sec
Reputation Power: 2458
Quote:
Originally Posted by honda259
Any advice will be greatly appreciated.
have you tried LIKE?

i mean, fulltext searching against that column seems like overkill
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book

Reply With Quote
  #3  
Old July 3rd, 2009, 01:14 PM
honda259 honda259 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2009
Posts: 3 honda259 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 47 m 16 sec
Reputation Power: 0
Thanks for the reply. The actual table has around 300,000 rows and the data is much longer eg "Black Cast Iron Fireplace Surround complete with fixing bracket"

I thought LIKE would be slow as I would have to use LIKE '%iron%' AND LIKE '%black%' which, correct me if im wrong, but this wouldnt use the index.

Also, using LIKE I have the problem of "megawidget" being returned on a search for '%widget%' (im not sure if the fulltext method will elimiate this, I havent got that far yet).

Again, thanks for your response

Reply With Quote
  #4  
Old July 3rd, 2009, 01:20 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 20,687 r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 1 Week 3 Days 9 h 27 m 54 sec
Reputation Power: 2458
Quote:
Originally Posted by honda259
Thanks for the reply. The actual table has around 300,000 rows and the data is much longer eg "Black Cast Iron Fireplace Surround complete with fixing bracket"
sheeeeit, man, i just answered the question you asked

you shoulda asked the real question in the first place

i am ~so~ tired of people asking the wrong questions and then not being happy with the answers they get

nothing against you personally, man, you're just the Nth guy to pull this stunt

Reply With Quote
  #5  
Old July 3rd, 2009, 01:29 PM
honda259 honda259 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2009
Posts: 3 honda259 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 47 m 16 sec
Reputation Power: 0
To be honest you didnt answer my question, my question was about Fulltext searches and my example was there to illustrate in simple terms what my problem was.

I dont consider my question to be a "stunt", if you dont want to help that is fine.

Reply With Quote
  #6  
Old July 3rd, 2009, 02:24 PM
Guelphdad's Avatar
Guelphdad Guelphdad is offline
Hockey face
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Nov 2001
Location: Guelph Canada
Posts: 7,579 Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 3 Days 16 h 26 m 23 sec
Reputation Power: 1069
actually your example was poor since you seemed to indicate that there were a single or couple of words in your column, rather than the second example where your terms are wrapped in a larger amount of text. that would have been better in your first post.

also believe that in your search you have searched for BLUE or WIDGET i.e. give me any blues, any widgets and of course any blue widgets.

if you want only BLUE WIDGET your + symbol belongs only at the beginning of the search and not in front of the second term.

so you likely want:

+ 'blue widget'

rather than '+widget +blue'

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Fulltext Search gives too many results


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




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

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




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
Stay green...Green IT