Auto-complete : do a middle search

Hello ,
I would like to introduce in the query field the like system as in the sql to be able to search for a telephone number starting with the middle example: +3367854456
my search is done like this: 67854456 without the telephone code
do you have any idea how to do it please?


You can use $regex operator:

  "phone": {
    "$regex": "67854456"

Working example

Hi NeNad ,

Thanx for your response but unfortunately I avoid the regex because it slows down the call to the api I would rather something like this :

   autocomplete: {
       query: `%${phoneSearch}%`,
       path: 'phone',

if it exists ?


the response of my question →

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.