0

I've been trying to come up with a way to properly fuzzy search using my Front End Database that calls a MySQL database.

At the moment, when someone searches, a PHP file is fired that calls a request to MySQL and MySQL does some pseudo fuzzy searching using Full Text Search and returns the closest match. This has worked semi-decently.

Today I came up with the idea of having the user load a full JSON file of the DB into their local storage when they load a page, then when they search it simply uses Javascript RegExp to filter through the JSON file stored in local storage to find the closest match.

However, I am worried that performance may be an issue or that this may be an extremely inefficient way of doing this.

Would storing a large (~7mb) JSON file into Local Storage be a bad idea?

GenesisBits
  • 364
  • 2
  • 23
  • 1
    Besides that local storage space might be limited (https://stackoverflow.com/questions/2989284/what-is-the-max-size-of-localstorage-values), requiring the user to download a 7MB file seems a bit much. You don't know what connection they have or how they are paying for the service. If it's for search, I assume that most of the data is actually not used by the user. The other question is how often this data updates and would need to be re-fetched. You might be better of using a service that is designed for full text search, such as elasticsearch. – Felix Kling Nov 28 '19 at 15:01
  • Agreed with @FelixKling. There is no reason to download 7MB to local storage. Better to look how to do a better fuzy search in MySQL itself or consider elastic search for optimization. – Segers-Ian Nov 28 '19 at 15:09
  • MySQL 8 now has JSON **native** array indexing.. something like `CAST(... AS ARRAY)` is now supported.. – Raymond Nijland Nov 28 '19 at 15:37

0 Answers0