As @NeNad points out, this question has been asked and answered many times. Another example is this question.
I'm just chiming in about two things in particular about the phrasing of this question that caught my attention. The first is:
if admin searches for example a number or a string if the there is a documnet with that value (or that value includes the admin input)
This type of searching can only be applied to string values. There is no concept of 3
being "in" the value of 537
. There is, however, the concept of the character "3"
being inside of the string "537"
.
The second thing somewhat overlaps with that and the includes(adminInput)
from the code. The direct $text
searching functionality provided in the database does not handle partial matches. You would likely need to look into alternatives such as Atlas Search or coupling Elasticsearch beside your MongoDB cluster to get the full functionality you are describing.