1

I have around 1M strings, new strings may be added or deleted once every month. And my goal is to perform fastest possible live search in those string, in react native. I will discuss about the approaches I have thought and the challenges I am facing in the approach,

  1. To request the backend on key hits and do a database lookup and return the result. This approach is too slow for my application's performance.

  2. Store the string locally and update the string once every month. I think this would be the best approach here but there are some problems I am facing in implementation. They are mentioned below,

    a) I am trying to convert the string into a trie data structure and search through it, but here the initial time for formation of trie and loading into memory is large and I feel it is not efficient. So is there a way to store the trie into the device and retrieve it somehow?

    b) Other approach is to store the data into frontend databases like Sqlite3 or something and query it for the result. But I am not sure how does the performance get affected?

Please help me with finding the most efficient way to find out the solution to the above problem, it may be outside of the approaches mentioned above. I have tried to be as elaborate as possible but do let me know if any more details is required.

Dexter
  • 236
  • 2
  • 12
  • You could construct the trie on the backend and send it as JSON. If the download is only done every month or so this could be the cheapest way for the device. JSON is also easy to store in AsyncStorage. Interesting problem! See this related answer (for a Python backend): https://stackoverflow.com/questions/51295864/matching-end-of-string/51296069#51296069 – Abe Apr 16 '22 at 01:20

0 Answers0