Advertisement

10.06.2008 at 03:22AM PDT, ID: 23789927
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

MySQL Full Text Conditional Query

Asked by ratlhead in MySQL Server

Tags:

I need some help optimizing a MySQL Full Text search query.  My example attached is using vehicles and technologies to simplify things.  I'm trying to accomplish the following:

1) A user enters keywords to search, in this case, vehicles
2) The full text search then looks at a manufacturer field and model field
3) In addition, the search looks to see if any of those keywords match a 'technology'

So an example query for "Toyota Camry" would return all cars that match.

The problem arises when the user enters a technology too.  For example, there might be a record for a "Camry Hybrid", and all I want returned are *those vehicles*.  However, since "hybrid" is also a technology, I also get results for any cars that have a hybrid as a technology.

But, I can't not search the 'technology' field because what if a user searches just 'hybrids'?

I hope these examples make sense.  I'm trying to come up with a way to optimize the search and make it smart enough to go only get the desired results, but given there's no way to know what a user might enter, I'm not sure how to move forward.  Perhaps multiple queries?Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
SELECT v.v_id
FROM vehicles v
WHERE (
	MATCH (v.manufacturer,v.model) AGAINST (\'' . $keywords . '\' IN BOOLEAN MODE) OR 
	v.technology_id IN (
		SELECT t.technology_id 
		FROM technologies t 
		WHERE MATCH (t.name) AGAINST (\'' . $keywords . '\' IN BOOLEAN MODE)
	)
)
[+][-]10.06.2008 at 07:54AM PDT, ID: 22650661

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.13.2008 at 02:25PM PDT, ID: 22706628

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: MySQL Server
Tags: MySQL
Sign Up Now!
Solution Provided By: ratlhead
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20081112-EE-VQP-44 / EE_QW_2_20070628