Hello! 👋 This application allows you to search lightning fast through restaurants in English, Thai, Indonesian and Japanese based on a variety of search parameters and data types:
- restaurant name
- food name
- geolocation coordinates
- cuisine type
- average star rating
- borough
Note1: This dataset is mocked. Please do not use to make actual dining decisions.
Note2: This demo is multiligual version of the What's Cooking repos.
What's Cooking implements many Atlas Search features from autocomplete to custom function scoring. Using the $search operator in a MongoDB aggregation pipeline, we can build fine-grained searches across text, numerics, and geospatial data. By building out What's Cooking, you'll learn all sorts of ways MongoDB allows you to build complex, fine-grained full-text searches on your Atlas data.
No additional servers or software needed. No need to keep data in sync. Everything is done in MongoDB Atlas.
- fuzzy matching
- highlighting
- autocomplete
- range queries
- geoqueries
- facets
- relevance-based scoring
- custom function scoring
- synonyms
Check out the demo video to see a demonstration of all the features or visit the link below to play around with the finished application, hosted entirely in MongoDB Atlas:
This application is hosted entirely by MongoDB Atlas was created using:
- React
- Tailwind CSS
- MongoDB Realm for backend HTTPs endpoints and functions
- A modified sample dataset based on MongoDB's Atlas sample_restaurants dataset
Currently this app is not suitable for mobile, but feel free to send a PR. 😊
- A MongoDB Atlas account. Get one for free here.
- Node.js version 16 and npm.
- Restaurant sample dataset.
- Synonyms dataset.
- (Recommended) MongoDB Compass - GUI
You can read and download the dataset using the MongoDB Shell, any MongoDB driver, or my favorite MongoDB Compass using the following URI:
mongodb+srv://mongodb:atlassearch@whatscooking.8u6sklg.mongodb.net/whatscooking
It is also included in this repo's data and indexes directory.
- Load data to Atlas cluster:
- database:
whatscooking - collection:
restaurants_[locale] (e.g. restaurants_en),menu_synonyms_[locale](e.g. menu_synonyms_en)
- database:
- Create Search indexes. (Index definitions includes in
indexesdirectory.) - default
- autocomplete
- facetIndex
Follow the instructions in Whatscooking BaaS using AWS Lambda Functions
You can test each HTTPS endpoints with the following commands commandcurl https://7voovjzrkjgdudds53so7rtsae0vjouf.lambda-url.ap-southeast-1.on.aws?restname=burger&locale=enresponse
[{"_id":"6095a34a7c34416a90d3212d","name":"Burger King","restaurant_id":"40370238"},{"_id":"6095a34a7c34416a90d3212e","name":"Burger King","restaurant_id":"40370167"},{"_id":"6095a34a7c34416a90d32135","name":"Burger King","restaurant_id":"40370239"},{"_id":"6095a34a7c34416a90d3214b","name":"Burger King","restaurant_id":"40370916"},{"_id":"6095a34a7c34416a90d32164","name":"Burger King","restaurant_id":"40370917"},{"_id":"6095a34a7c34416a90d32166","name":"Burger King","restaurant_id":"40372422"},{"_id":"6095a34a7c34416a90d3216b","name":"Burger King","restaurant_id":"40372618"},{"_id":"6095a34a7c34416a90d321b4","name":"Cozy Soup \u0026 Burger","restaurant_id":"40375839"},{"_id":"6095a34a7c34416a90d3228a","name":"Burger Barn Restaurant","restaurant_id":"40384486"}]
command
curl \
-H "Content-Type: application/json" \
-d '{"searchTerm": "burger ", "food": "", "operator": "text", "dist": 1, "stars": 1, "cuisine": [], "locale": "en"}' \
https://f6lhyweuc6xvqp5jylghwt7v5u0qzwjz.lambda-url.ap-southeast-1.on.aws
response
{"aggString":"[{\"$search\":{\"text\":{\"query\":\"burger \",\"path\":\"name\",\"fuzzy\":{\"maxEdits\":2}}}},{\"$limit\":21},{\"$project\":{\"name\":1,\"cuisine\":1,\"borough\":1,\"location\":1,\"menu\":1,\"restaurant_id\":1,\"address.street\":1,\"stars\":1,\"review_count\":1,\"PriceRange\":1,\"sponsored\":1,\"score\":{\"$meta\":\"searchScore\"},\"highlights\":{\"$meta\":\"searchHighlights\"}}}]","restaurants":[{"_id":"6095a4864ba3a04a69a79eba","address":{"street":"Pearl Street"},"borough":"Manhattan","cuisine":"Hamburgers","name":"Burger Burger","restaurant_id":"41316784","location":{"type":"Point","coordinates":[-74.0105051,40.7040805]},"stars":3.5,"review_count":159,"menu":["Bacon burger","Santa Fe burger","Ahi Tuna burger","Cheeseburger","Loaded Fries","Mushroom swiss burger","Hickory burger","Classic burger","Fajita burger","Oldtimer with cheese","French Fries","Vegetarian burger"],"PriceRange":2,"score":3.3074374198913574},{"_id":"6095a34a7c34416a90d3212d","address":{"street":"Northern Boulevard"},"borough":"Queens","cuisine":"Hamburgers","name":"Burger King","restaurant_id":"40370238","location":{"type":"Point","coordinates":[-73.89707140000002,40.7543896]},"stars":3,"review_count":38,"menu":["Cheeseburger","Ahi Tuna burger","Chili Cheeseburger","Buffalo Fries","Vegetarian burger","Loaded Fries","French Fries","Classic burger","Triple layer burger","Oldtimer with cheese","Hickory burger","Oldtimer"],"PriceRange":2,"score":2.49027419090271}, ...}
command
curl \
-H "Content-Type: application/json" \
-d '{"searchTerm": "burger", "food": "", "operator": "text", "dist": 1, "stars": 1, "cuisine": [], "locale": "en"}' \
https://cwoaaqy74pwe76cajhevu7kaby0eutbe.lambda-url.ap-southeast-1.on.aws
response
{"results":[{"count":{"lowerBound":183},"facet":{"cuisineFacet":{"buckets":[{"_id":"Hamburgers","count":105},{"_id":"American","count":69},{"_id":"Other","count":3},{"_id":"Jewish/Kosher","count":2},{"_id":"Pizza/Italian","count":2},{"_id":"Latin (Cuban, Dominican, Puerto Rican, South \u0026 Central American)","count":1},{"_id":"Mexican","count":1}]},"boroughFacet":{"buckets":[{"_id":"Manhattan","count":69},{"_id":"Brooklyn","count":47},{"_id":"Queens","count":36},{"_id":"Bronx","count":23},{"_id":"Staten Island","count":8}]}}}],"searchMetaStageString":"{\"$searchMeta\":{\"index\":\"facetIndex\",\"facet\":{\"operator\":{\"text\":{\"query\":\"burger\",\"path\":[\"name\",\"cuisine\"]}},\"facets\":{\"cuisineFacet\":{\"type\":\"string\",\"path\":\"cuisine\"},\"boroughFacet\":{\"type\":\"string\",\"path\":\"borough\"}}}}}","searchMetaStage":{"$searchMeta":{"index":"facetIndex","facet":{"operator":{"text":{"query":"burger","path":["name","cuisine"]}},"facets":{"cuisineFacet":{"type":"string","path":"cuisine"},"boroughFacet":{"type":"string","path":"borough"}}}}},"ok":true}
command
curl https://nqez7rq6c6hkbsydjsf3ktpfru0qkaan.lambda-url.ap-southeast-1.on.aws?locale=en
response
{"foodSynonyms":[{"_id":"6268a01b5899f60be615cb66","input":["noodles"],"mappingType":"explicit","synonyms":["lo mein","chow mein","pasta","udon","ramen","spaghetti","alphabetti","macaroni","pasta"],"date_inserted":"2022-04-27T01:44:59.057Z","editable":false}],"ok":true}
- Clone the repo.
- Navigate inside
whatscooking-multilingualdirectory. - Run
npm install. - Change HTTPS endpoint urls at
src/hooks/useHomeFetch.jsto your own ones. - Change HTTPS endpoint urls at
src/compenents/SearchBar.jsto your own one. - Change MongoDB Connectionstring at
src/pages/IndexPage.jsto your own one. - Run
npm start.
- Make sure that you're using NodeJS v16 to successfully build the artifacts. If you're using nvm to manage your Node version, just type
nvm useto swich to the correct NodeJS version - Set AWS temporary credentials in your environment variable and ensure that you're pointing to the correct AWS account
- Run
./deploy_to_s3.sh - The S3 bucket is fronted by CloudFront, so it might take a while for the cache to be refreshed. If you want invalidate the cache manually, following the instructions when you run the script
What's Cooking uses AWS Lambda Functions to create 5 APIs to allow you to query for your restaurant data over HTTP:
GetRestaurantsEndPointcalled from theuseHomeFetch.jshook.GetFacetsEndpointcalled from theuseHomeFetch.jshook.Suggestions_AC_Endpointcalled from theSearchBar.jscomponent.getSynonymscalled in theSynonymsPage.js.






