In my current project, I am facing a challenge where I need to handle an array of strings received from the frontend. Each document in my mongoDB database also has its own array of keywords. The tricky part is that the strings sent from the frontend might just be substrings of the keywords stored in the database. My goal is to query the database in such a way that it retrieves all documents containing all the keyword substrings provided.
For example:
Keyword array for Document 1: ["substation", "220/60", "kV"]
Keyword array for Document 2: ["substation", "220", "kV", "delhi"]
Keyword array for Document 3: ["substation", "kV", "Bombay"]
Array received from the frontend: ["substa", "220"]
I expect the database to return the first two documents because both elements of the received array are present as substrings of keywords in those documents. However, the third document should not be included in the results since it does not have "220" among its keywords. So far, I have struggled to come up with a suitable query to achieve this functionality.