This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Sample data */ | |
insert into emp (EMPID, NAME, JOB, SALARY) | |
values | |
(201, 'ANIRUDDHA', 'ANALYST', 2100), | |
(212, 'LAKSHAY', 'DATA ENGINEER', 2700), | |
(209, 'SIDDHARTH', 'DATA ENGINEER', 3000), | |
(232, 'ABHIRAJ', 'DATA SCIENTIST', 2500), | |
(205, 'RAM', 'ANALYST', 2500), | |
(222, 'PRANAV', 'MANAGER', 4500), | |
(202, 'SUNIL', 'MANAGER', 4800), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Query stats | |
pprint(db.restaurants.find({'cuisine':'French','grades.score':{'$gt':5}}).explain()['executionStats']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Query stats | |
pprint(db.restaurants.find({'cuisine':'American'}).explain()['executionStats']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pprint(db.restaurants.find().explain()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Multiple token search | |
db.restaurants.find_one({"$text": {"$search": "Chinese -Restaurant"}}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Multiple token search | |
db.restaurants.find_one({"$text": {"$search": "Chinese Kitchen"}}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find restaurants with Kitchen in their name | |
db.restaurants.find_one({"$text": {"$search": "Kitchen"}}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Drop indexes | |
db.restaurants.drop_indexes() | |
# Create text index | |
db.restaurants.create_index([('name', 'text')], | |
name='restaurant_name') | |
# List indexes | |
pprint(db.restaurants.index_information()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Query stats | |
pprint(db.restaurants.find({'cuisine':'French'}).explain()['executionStats']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Query stats | |
pprint(db.restaurants.find({'cuisine':'French','grades.score':{'$gt':2}}).explain()['executionStats']) |
NewerOlder