1) I have a string with about 30 comma seperated elements. Like str1, str2, str3 etc. "INPUT_STRING"
2) I have mongo db collection "allowed_strings". For instance, str1, str2, str3 etc. There are 1500 strings and in future would be max 2000. ALLOWED_STRING collection.
3) I need to take IN_STRING and match ALLOWED_STRING. As a result create new json array (or comma seperated string) "MATCHED".
4) In reality it is a bit more complex as str1, str2 etc. often comes in different forms like str-1 instead of str1. Or there could be also synonyms of str1 (for instance, syn1) that are stored in "allowed_strings.synonyms" collection.
I never worked with mongodb and node js. And here I have two solutions in mind:
- First: there are not so many elements in total (only 2000 elements in collection
ALLOWED_STRINGand about 30 elements in comma separated stringINPUT_STRING); I can read all collection into node js memory at once and then do search using node js (including custom search by synonyms etc.)
OR
- SECOND: I can loop through comma separated strings "IN_STRING" taking elements one by one (str1, then str2 etc.) and each time perform mongo db query
Which is better?