I am using $text and $search to search fields including query text partially.

For example, fields is following.

{ first_name: "Frist Name", last_name: "Last Name", email:"[email protected]"}

If I type "na" in search field, I want to get all fields including "na".

How can I get fields on node.js.

1 Answers

0
tom slabbaert On

To do that you want to use a regex, be aware though that this does NOT use the text index you've built.

it would look like this:

  {email: new RegExp(".*na.*")}