PHP script that implements a search algorithm using MySQL Full Text Search feature.
The algorithm:
- Take the search text string and split it into a list of words.
- Remove all "stopwords" (See: https://en.wikipedia.org/wiki/Stop_words) from the previous list. The remaining words will be called "keywords".
- Apply a stemming algorithm over the list of keywords (See: https://en.wikipedia.org/wiki/Stemming).
- Construct and execute an SQL query (SELECT) over an arbitrary list of "Full Text Search" indexed fields (MATCH) and using the previous list of words stems (AGAINST).
- Fetch the obtained search results.
There is an example of use in "example" folder. The frontend part of the example is implemented using VueJS framework.
How to deploy example:
- Clone (or download and unzip) this repository.
- Install Composer, if you don't have it installed (See: https://getcomposer.org/).
- Open the repository folder in a terminal console and run the following command: "composer install"
- Create a MySQL database called "test" and import the "test.sql" file (found in "example" folder).
- See "config.php" (found in "example" folder) file comments and choose between PDO handler and MySQLi handler.
- Open a web browser and navigate to "example" folder.