
- MongoDB Tutorial
- MongoDB - Home
- MongoDB - Overview
- MongoDB - Advantages
- MongoDB - Environment
- MongoDB - Data Modeling
- MongoDB - Create Database
- MongoDB - Drop Database
- MongoDB - Create Collection
- MongoDB - Drop Collection
- MongoDB - Data Types
- MongoDB - Insert Document
- MongoDB - Query Document
- MongoDB - Update Document
- MongoDB - Delete Document
- MongoDB - Projection
- MongoDB - Limiting Records
- MongoDB - Sorting Records
- MongoDB - Indexing
- MongoDB - Aggregation
- MongoDB - Replication
- MongoDB - Sharding
- MongoDB - Create Backup
- MongoDB - Deployment
- MongoDB - Java
- MongoDB - PHP
- Advanced MongoDB
- MongoDB - Relationships
- MongoDB - Database References
- MongoDB - Covered Queries
- MongoDB - Analyzing Queries
- MongoDB - Atomic Operations
- MongoDB - Advanced Indexing
- MongoDB - Indexing Limitations
- MongoDB - ObjectId
- MongoDB - Map Reduce
- MongoDB - Text Search
- MongoDB - Regular Expression
- Working with Rockmongo
- MongoDB - GridFS
- MongoDB - Capped Collections
- Auto-Increment Sequence
- MongoDB Useful Resources
- MongoDB - Questions and Answers
- MongoDB - Quick Guide
- MongoDB - Useful Resources
- MongoDB - Discussion
Searching a specific domain name from URL records in MongoDB?
To search for a specific domain name, use /i. Let us create a collection with documents −
> db.demo219.insertOne({"details":{"WebsiteURL":"www.EXAMPLE.com"}}); { "acknowledged" : true, "insertedId" : ObjectId("5e3e667203d395bdc2134718") } > db.demo219.insertOne({"details":{"WebsiteURL":"www.gmail.com"}}); { "acknowledged" : true, "insertedId" : ObjectId("5e3e667803d395bdc2134719") } > db.demo219.insertOne({"details":{"WebsiteURL":"www.example.com"}}); { "acknowledged" : true, "insertedId" : ObjectId("5e3e667f03d395bdc213471a") }
Display all documents from a collection with the help of find() method −
> db.demo219.find();
This will produce the following output −
{ "_id" : ObjectId("5e3e667203d395bdc2134718"), "details" : { "WebsiteURL" : "www.EXAMPLE.com" } } { "_id" : ObjectId("5e3e667803d395bdc2134719"), "details" : { "WebsiteURL" : "www.gmail.com" } } { "_id" : ObjectId("5e3e667f03d395bdc213471a"), "details" : { "WebsiteURL" : "www.example.com" } }
Following is the query to search a specific domain name −
> db.demo219.find({"details.WebsiteURL": /example/i});
This will produce the following output −
{ "_id" : ObjectId("5e3e667203d395bdc2134718"), "details" : { "WebsiteURL" : "www.EXAMPLE.com" } } { "_id" : ObjectId("5e3e667f03d395bdc213471a"), "details" : { "WebsiteURL" : "www.example.com" } }
- Related Articles
- Difference Between URL and Domain Name
- What is the difference between Domain Name and URL?
- Domain Resource Records
- Searching 2 fields at the same time to fetch a specific First Name and Last Name from a table in MySQL
- Find records on or after a specific date in MongoDB?
- How to get details of a webpage like url, title name, domain name etc using Javascript Executor in Selenium?
- MongoDB Query to search for records only in a specific hour?
- Find MongoDB records with Price less than a specific value
- Searching for ranges in MongoDB?
- How to select domain name from email address in MySQL?
- Filter specific values from a MongoDB document
- What is a Domain Name System?
- MongoDB query to group records and display a specific value with dot notation
- MySQL query to select records beginning from a specific id
- Find out the popular domains from a MySQL table with domain records and search volume

Advertisements