I have a finished Chinese-English dictionary website as a personal project and it works pretty great. I'm using node/Express with node-dirty, which is a barebones file-based JSON database that loads everything into memory on start-up. As I keep adding more features though, I have to continuously update my database generation scripts (tedious string manipulation) and server start-up load times are a couple minutes. I'm also in later need of implementing paging.

I'm interested in potentially moving to a more typical database (MongoDB, for instance).

Being everything is in-memory with node-dirty, I just loop through the entire thing, check exact matches or edit distance and I'm good to go. Even with 120,000 entries it takes less than 50ms (for one user of course).

How does one search with a typical database? I'm not sure how I would narrow down the result set with Chinese/pinyin/English matches in a query or if I would have to store all the results in memory like I do now and parse through them in the service side.

I'm not really interested in "how Google searches the internet" (nor have I studied advanced algorithms) but a simple sensible solution for a hobbyist.

  • Duplicate doesn't answer my question, but I can't think of how to better word it so it's not marked as a duplicate. Commented Feb 4, 2017 at 19:42
  • 1
    Have a look here: softwareengineering.stackexchange.com/q/54320/63202 for some ideas. If you can precompute useful values and store them in the database, you can use the database's query mechanisms. Otherwise, you have to do your match algorithm pretty much outside the db.
    – Erik Eidt
    Commented Feb 4, 2017 at 20:05
  • @ErikEidt Thanks for the link and advice. I'll look into it for ideas. Commented Feb 5, 2017 at 18:29


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.