How to search a MySQL table for a website

How do I perform a search similar to a Wikipedia search on a MySQL table (or multiple tables at a time) without first traversing the database? (Wikipedia search is used to show relevance as a percentage).

I'm looking here for how to determine the relevance of the results and sort them accordingly, especially in the case where you are fetching data from multiple tables at once.

What do you use for the search function on your sites?

+2


source to share


1 answer


You can use MySQL full text search . You must have a FULLTEXT index to search for fields. For natural language searches, it returns a relevance value that is "a measure of the similarity between the search string and the text in that string."



If you are looking for multiple tables, the relevance value should be comparable across multiple results; you can make a UNION of separate full text queries on each of the tables and then sort the join results based on the relevance value.

+2


source







All Articles