473,750 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP / MySQL relevance in searching

gregerly
192 Recognized Expert New Member
Hello,

I've got a problem with a website search function. PHP for the front end, MySQL for the backend. The search function searches a field of keywords. The problem I'm having is that when someone searches for "Italian Food" it's bring back results for other resteraunts that are not italian, but do have the word Food in their keywords. Is there a way of adding relevance to a search, in a way that would make sense for the above senario?

Thanks in advance,

Greg
Jul 12 '07 #1
7 5269
pbmods
5,821 Recognized Expert Expert
Heya, Greg.

If your database uses MyISAM tables, you can use MySQL fulltext searching.
Jul 12 '07 #2
dafodil
392 Contributor
fulltext is good because it offers different format of searches and if you're using the like keyword in your search remove it so that you can direct search....
Jul 13 '07 #3
gregerly
192 Recognized Expert New Member
This looks like what I've been looking for. One thing I still don't understand about FULLTEXT searches, lets say I have four records:

1. Italian Food
2. Mexican Food
3. German Food
4. Chinese Food

Lets say my search is "Italian Food", where the word "Food" is in all results, but "Italian" is in only one. Does mysql filter out the three records that do not have "Italian" in the result?

I'm thinking this is definelty the way to go, I just am trying to wrap my head around exactly how it works.

Thanks,

Greg
Jul 13 '07 #4
Botondus
9 New Member
A natural language search interprets the search string as a phrase in natural human language (a phrase in free text). There are no special operators. The stopword list applies. In addition, words that are present in more than 50% of the rows are considered common and do not match. Full-text searches are natural language searches if the IN NATURAL LANGUAGE MODE modifier is given or if no modifier is given.
So if you use the IN NATURAL LANGUAGE MODE option it should give you only 1 result: Italian Food, from that particular list.

Anyway you can use something like:
Expand|Select|Wrap|Line Numbers
  1. SELECT ... MATCH () AGAINST() as score from .... WHERE MATCH () AGAINST () order by score desc;
And use only the first x rows, that contain the x most relevant results, if you don't want to show results with low relevance.
Jul 13 '07 #5
dafodil
392 Contributor
This looks like what I've been looking for. One thing I still don't understand about FULLTEXT searches, lets say I have four records:

1. Italian Food
2. Mexican Food
3. German Food
4. Chinese Food

Lets say my search is "Italian Food", where the word "Food" is in all results, but "Italian" is in only one. Does mysql filter out the three records that do not have "Italian" in the result?

I'm thinking this is definelty the way to go, I just am trying to wrap my head around exactly how it works.

Thanks,

Greg
Yes mysql filters out the other foods... So what have you decided did you use the full text or the direct search? in fulltext you use the keyword match() and against()...
Jul 13 '07 #6
gregerly
192 Recognized Expert New Member
Yes mysql filters out the other foods... So what have you decided did you use the full text or the direct search? in fulltext you use the keyword match() and against()...
I think i'm going with the full text search. Seems to be what I'm looking for. I'll post back here when I'm done and let yall know how it works.

Thanks again for the help. You guys/gals are a wealth of info.

Greg
Jul 14 '07 #7
pbmods
5,821 Recognized Expert Expert
Heya, Greg.

Thanks again for the help. You guys/gals are a wealth of info.
We aim to please.

Good luck with your project, and if you ever need anything, post back anytime :)
Jul 14 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

6
1585
by: lawrence | last post by:
I've spent some time going over this page: http://dev.mysql.com/doc/mysql/en/Data_Manipulation.html And so far it seems the answer is no. So I thought I'd ask here. Does anyone know of any built-in search algorithms with MySql? I'm looking for a way to return the results of my last SELECT statement (which uses LIKE) based on the number of hits the LIKE came up with. In other words, I want something like this:
1
1946
by: Hal Halloway | last post by:
How do I change a MYSQL Fulltext relevance value to: 0 to 100%. I'm just thinking about usability for the "average" user - maybe they would like to know...and would not understand the raw value. Any snips, ideas or links appreciated. Thanks
4
2764
by: Michi | last post by:
I was wondering what the best solution is for making large numbers of TEXT (or BLOB?) fields searchable. For example, if I have a forum, what is the best way to be able to search for specific words? How about exact phrases? I saw a solution where all words are preindexed in a "dictionary" like table and then another table stores the word matches. That seems really fast, but it has two major problems: 1) it can't do exact matches, and 2)...
17
2902
by: chicha | last post by:
Hey people, I have to convert MS Access 2000 database into mysql database, the whole thing being part of this project I'm doing for one of my faculty classes. My professor somehow presumed I knew db's and gave me long list of things to do with that particular database, first thing being that particular conversion. Truth is that I don't know a first thing about db's, let alone using mysql... I downloaded mysql form www.mysql.com and...
2
2369
by: Paul Bramscher | last post by:
What are the mechanisms to make words like a/an/the in text and varchar character fields ignored when performing SELECT and utilizing ORDER BY in SQL queries? I've done some hunting around into documentation on character sets (but they are geared mainly at character-by-character rules) and saw some reference to string collating and stop words -- but not seen any of this all put together. Thanks for any assistance,
15
4638
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to communicate with a MySQL database table on a web server, from inside of my company's Access-VBA application. I know VBA pretty well but have never before needed to do this HTTP/XML/MySQL type functions.
2
1447
by: Richard Brosnahan | last post by:
I hate asking questions that have probably been answered before, but I have not found a way to conveniently search the archives of this mailing list. So... Can someone tell me how to search this mailing list, short of downloading every month's archive and searching manually? Or, can someone tell me how to easily interface with MySQL with
4
1721
by: | last post by:
Hello... i have a table which contains a column named "ask" and a column named "per"... my think is that i want to search in "ask" and echo the data stored in "per" for this entry... How do i do this? Thanx in advance! JBK
2
1655
gregerly
by: gregerly | last post by:
Hello, I appologize as I've posted this in the PHP forum as well, but I think it is relevant here as well. I've got a problem with a website search function. PHP for the front end, MySQL for the backend. The search function searches a field of keywords. The problem I'm having is that when someone searches for "Italian Food" it's bring back results for other resteraunts that are not italian, but do have the word Food in their keywords. Is...
0
9000
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9396
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9339
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9256
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6081
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4713
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4887
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3322
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2804
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.