Home arrow MySQL arrow Page 6 - Getting Started With MySQL's Full-Text Search Capabilities
MYSQL

Getting Started With MySQL's Full-Text Search Capabilities


Need a rock-solid, powerful search solution for your PHP/MySQL driven web site? In this article Mitchell introduces us to MySQL's full-text and Boolean search capabilities.

Author Info:
By: Mitchell Harper
Rating: 5 stars5 stars5 stars5 stars5 stars / 119
August 26, 2002
TABLE OF CONTENTS:
  1. · Getting Started With MySQL's Full-Text Search Capabilities
  2. · What is Full-Text Searching?
  3. · What is Full-Text Searching (contd.)
  4. · Full-Text Rules And The MATCH Command
  5. · Performing A Boolean Search
  6. · Conclusion

print this article
SEARCH DEVARTICLES

Getting Started With MySQL's Full-Text Search Capabilities - Conclusion
(Page 6 of 6 )

In this article we've seen how to setup and use MySQL full-text and Boolean searches. Just to reiterate, here are the steps you need to take to get full-text working on your database:

1. Create/alter a table, making sure a call to the FULLTEXT command is issued when creating/altering the table.

2. To perform a full-text normal search, use the MATCH and AGAINST commands in your query for fields that have been marked as full text, like this:

SELECT *, MATCH(field1, field3) AGAINST('my_query') as relevance FROM myTable WHERE MATCH(field1, field3) AGAINST('my_query')

4. To perform a full-text Boolean search, use the MATCH and AGAINST commands in combination with the IN BOOLEAN MODE keywords in your query for fields that have been marked as full text, like this:

SELECT *, MATCH(field1, field3) AGAINST('my_query' IN BOOLEAN MODE) as relevance FROM myTable WHERE MATCH(field1, field3) AGAINST('my_query IN BOOLEAN MODE')

Using the examples and information provided in this article you should now be able to create a basic full-text search against your database. Simply use a scripting language such as PHP to gather a search query from your users. Next, pass this string to your MySQL query as the parameter to the AGAINST command. Lastly, iterate through the results, displaying the relevance ranking if desired.

In my next article I will create a full-text search engine using PHP, MySQL and MySQL's full-text Boolean search capabilities. Until then, visit our forums.
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

blog comments powered by Disqus
MYSQL ARTICLES

- MySQL and BLOBs
- Two Lessons in ASP and MySQL
- Lord Of The Strings Part 2
- Lord Of The Strings Part 1
- Importing Data into MySQL with Navicat
- Building a Sustainable Web Site
- Creating An Online Photo Album with PHP and ...
- Creating An Online Photo Album with PHP and ...
- PhpED 3.2 More Features Than You Can Poke ...
- Creating An Online Photo Album with PHP and ...
- Creating An Online Photo Album with PHP and ...
- Security and Sessions in PHP
- Setup Your Personal Reminder System Using PHP
- Create a IP-Country Database Using PERL and ...
- Developing a Dynamic Document Search in PHP ...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials