Tinysearch
A simple search engine in Python (for a talk at PyTennessee 2017)
Install / Use
/learn @jorendorff/TinysearchREADME
tinysearch
This repository contains a tiny search engine, in just 140 lines of Python. Originally written for PyTennessee 2017.
The challenge
Change this search engine to recognize exact phrases and boost them up to the top of the search results.
Explanation: If you run this search engine and search for hot chicken,
you'll get this:

And if you search for batman building, you'll get this:

We want to see Nashville%2C-Tennessee.txt at the top of both queries.
The information you need to do this is already in the index.
How to run this search engine
-
clone this repository
-
download either sample.tar.bz2 or sample.zip and untar/unzip it in your
tinysearchdirectory. -
python3 tiny.py small-sampleto create a search index! -
pip install flask -
FLASK_DEBUG=1 FLASK_APP=web.py flask runto start the web server!
Then you can go to http://localhost:5000/ to see the toy search engine.
How to switch to the large sample
The instructions above only search 50 files. To search all 8,000+ files, make these two changes:
-
python3 tiny.py large-sampleto create the index. This takes ~5 minutes. -
In
web.py, just change the string"small-sample"to"large-sample". (When you save that file, Flask will notice and automatically restart your web server.)
