I am about to implement a search bar in my application, and trying to think of the best method of doing so. I have a MySQL database with a number of fields and want them to be able to search by any of them. Even multiple fields at once if possible(preferred).
I have thought of two possible approaches: 1 - I create a massive list which references every record. So it will have all the data from field a, b etc. Then the search will return the record you searched for (or list of records depending on if there are duplicates). My issue with this is I fear it will become very slow as the database size increases. Also, searching for multiple fields simultaneously will be an issue.
2 - I add a dropdown where the user can select which field to search by. Then write the queries for each field.
Is there a better way of doing this? We are using prime faces for the front end (if that makes a difference)
Aucun commentaire:
Enregistrer un commentaire