0

I have a url field as:

db.test.insert({"url":"https://www.google.com/shopping/product/1/online?prds=pid:11247610123343072928,https://www.google.com/shopping/product/1/online?prds=pid:1124761012334307256565"})

but when I do

db.test.find({"url": {"$regex":"https://www.google.com/shopping/product/1/online?prds=pid:11247610123343072928"}})

It returns nothing. I want to find all documents that matches a substring. What am I doing wrong?

1 Answer 1

2

You just need to ignore special character and then your query will work. Try using query below:

db.test.find({"url": {"$regex":"https://www.google.com/shopping/product/1/online.*\\?.*prds=pid:11247610123343072928"}})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.