Plain text search to ... modules?

43 views
Skip to first unread message

Jeremy Darling

unread,
Nov 7, 2014, 2:29:10 PM11/7/14
to nodejs
This seems like a common enough scenario that their is probably already a module for it, so I'm asking before I start writing one :).

Given a generic free form text search input on a webpage I would like to have it converted over to a query to be executed against my data.  My target is MongoDB like query instructions, but doesn't have to be MongoDB as could easily transform it again.

Something like:

foo and bar

might result in something like:

{
  $or: [
    {name: /foo and bar/i},
    {description: /foo and bar/i},
    {$and: [
      {name: /foo/i},
      {name: /bar/i},
    ]},
    {$and: [
      {description: /foo/i},
      {description: /bar/i},
    ]},
    ...etc...
  ]
}

Has anyone already done something similar that is out there and easy to include, or is this something that still needs to be created?

Thanks,
 - Jeremy

greelgorke

unread,
Nov 10, 2014, 4:49:42 AM11/10/14
to nod...@googlegroups.com
i have used https://github.com/tj/node-monquery but beware, the maintainer isn't doing node anymore.

Jeremy Darling

unread,
Nov 10, 2014, 11:11:59 AM11/10/14
to nodejs
Thanks, if nothing else that's a great starting point :)

--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
To post to this group, send email to nod...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/ce4a5368-fa04-455a-bdeb-0a172c4738d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages