← All projects
Information retrieval · UC Riverside CS 242 · team of four

Wikipedia
Search Engine

A search engine built from scratch over Wikipedia's law articles: a crawler, a classic keyword index and two neural indexes, with an app that runs one query against all three so you can see how lexical and semantic search differ.

PythonScrapyPyserini / Lucenesentence-transformersFAISSFlask

my part: the crawler that built the corpus

01 · The goal

Keywords or meaning?

BM25, the scoring behind classic search engines, matches the words in a query. Dense retrieval embeds the query and every passage as vectors and matches on meaning instead. The project builds both over the same corpus and puts them side by side, along with a second neural model: generic bert-base-uncased against msmarco-distilbert-base-v4, which was trained for search.

02 · System

Crawl, index twice, search.

CrawlScrapyBreadth-first from the Law article, following article links only and keeping body text.
LexicalBM25 on LuceneA Pyserini index over title and text, with positions and stored documents.
Chunk512-token passagesOverlapping by 64 tokens so ideas aren't cut at a boundary.
SemanticFAISS, two models768-dim normalized embeddings, exact cosine search.
CompareFlask appOne query, three engines, one best passage per page, with query time shown.

The crawler was my part. It started as a depth-first crawl that wandered off topic quickly. Switching to a breadth-first queue with depth priority kept it close to the starting article and raised the share of law pages. A stricter category filter improved relevance further but slowed the crawl too much to keep.

03 · Scale

The corpus in numbers.

0pages crawled (620 MB of text)
0passages embedded per model
0dimensions per vector
~0 GBper dense index, vs. ~0.76 GB for Lucene

Dense indexing time grows with the corpus

1,000 pages
23 min
2,000 pages
46 min
5,000 pages
1 h 40 min
10,000 pages
3 h 18 min

Embedding the MS MARCO model's passages took about 1.2 seconds per page, close to linear. The whole Lucene index built in well under a minute, which is the practical trade-off between the two approaches.

04 · Lessons

What I'd do next.

Measure relevance, not just speed

The project timed every index but never scored result quality. A set of labeled queries with precision@k or nDCG is the missing piece for saying which engine is better.

Deduplicate before indexing

Redirect pages were saved as separate documents, so the same article could appear several times in BM25 results. Resolving redirects at crawl time would fix it.

A fair baseline

Generic BERT isn't trained for retrieval, so it's a weak opponent for the MS MARCO model. A retrieval-tuned model of similar size would make the comparison sharper.

Crawl politely

The crawl ignored robots.txt. A rerun should respect it, or use Wikipedia's database dumps, which are the intended way to get text at this scale.