0

I have a collection of documents with a field called "idPattern" containing regex string. I want to search all documents that their fields "idPattern" regex string matches with my search string or a substring of it. How can I perform it?

Example:

Document:

{
"_id":....,
"_rev":....,
"idPattern":"*"
},
{
"_id":....,
"_rev":....,
"idPattern":"park"
},
{
"_id":....,
"_rev":....,
"idPattern":"stree*"
}

Search by: "park_central"

The first two documents should be returned.

Thank you.

  • I'm not sure I follow what your intent is. You want to always search for `_id:******` etc? Are they comma separated? Do you know how many digits each are? How are you determining which capture group you want to capture? – Joel Hager May 02 '20 at 03:48
  • idPattern isn't about _id. For example, we have this query: {"id": {"$regex": "regular_expression"}} I will search using a regular expression and it will return all elements their fields called id matches the regex. I want something inverse of it. The regex stays in the field, and it should match with my search. – Douglas Lima Dantas May 02 '20 at 03:52
  • What do you mean by by saying "I want something inverse of it"? It would be helpful to show what you've tried (query selector for example). Is this a `couchdb` question or a `regex` question? – RamblinRose May 06 '20 at 12:43

0 Answers0