5 points · by xoredev · 1mo ago · 3 comments
My goal was to reach 1% of Google's index. This is 4 billion pages across 33.5 million domains. I was inspired by the earlier attempts shared here: "Building a web search engine from scratch with 3B neural embeddings" [1] and "Crawling a billion web pages in just over 24 hours" [2]. I decided not to replicate them and instead used CommonCrawl corpus, built a pipeline, and threw the results into a classic full-text search index.
First, I got my hands on a dedicated Hetzner server with 4x10TB HDDs. It allowed me to crunch CommonCrawl data and stay within my hobby budget. The backend is served from a similar "home-grade" server but with NVMe disks instead. The compressed index weighs just over 2TB because I cap content length at 4KB per page (p50=2.9KB, p99=46KB) to fit it on disk. I picked Rust for my project. After years of big data engineering on the JVM, Rust felt like a breath of fresh air. I ended up not using any special data processing libraries - the pipeline is relatively straightforward and runs without crashes. As for full-text search, tantivy was an obvious choice. It took some time to get single query latency down to an acceptable ~350ms, although concurrent requests quickly max out disk t/p at 6.1GB/s and latency starts to climb. The search algorithm is primitive by modern standards: top 1,000 candidates are retrieved using BM25 (text relevance signal) and then reranked with PageRank [3].
Turns out you can fit the whole internet in a single server rack. The challenge here, of course, is to keep it up to date, especially if you don't have unlimited (crawl) budget. Right now I'm looking for funding or sponsorship to get extra hardware. That would allow me to scale the project and keep it free to use. I can also periodically dump the index on HuggingFace for research purposes. Any suggestions are welcome.
[1] https://news.ycombinator.com/item?id=44878151
HTTPS is optional
For example, something like
read x
xx=$(echo $x|sed 's/ */ /g;s/ /+/g')
printf 'GET %s HTTP/1.1\r\nHost: %s\r\nConnection: %s\r\n\r\n' \
'/search?hl=&source=&biw=&bih=&q='${xx}'&btnI=&iflsig=&gbv=' \
'www.google.com' \
'close' \
|bssl client -connect 142.251.156.119:443 \
|sed -n '
/^<HTML>/p
/^<TITLE>/s/302 Moved//p
s/<A HREF=\"https:\/\/www.google.com\/url?q=//;
s/<A HREF=\"http:\/\/www.google.com\/url?q=//;
s/\">here<\/A>.//
/^https:\//{s/^/1. <a href="/p;}
/^1. <a href="https:\//s/.\{12\}/ ">/p
/^">https:\/.*/s//<\/a>/p
/^http:\//{s/^/1. <a href="/p;}
/^1. <a href="http:\//s/.\{10\}/ ">/p
/^">http:\/.*/s//<\/a>/p
/^<\/BODY>/p
'
#example usage:
#echo the best search engine|$0 > 1.htm
#firefox ./1.htm
The "catch" is that there's only one search result, "one blue link" instead of tenGiven the ever-increasing emphasis on the so-called "top result" in www search this may be acceptable for many users
Also, currently we can still retrieve some "auto completion" results without "AI" suggestions, Javascript, cookies or ads
HTTPS is optional
For example, something like
read x
xx=$(echo $x|sed 's/ */ /g;s/ /+/g')
printf 'GET %s HTTP/1.0\r\nHost: %s\r\n\r\n' \
'/complete/search?client=heirloom-hp&hl=en&gs_rn=35&gs_ri=heirloom-hp&cp=3&gs_id=7&q='${xx}'&gs_gbg=' \
'clients1.google.com' \
|bssl client -connect 192.178.155.102:443 \
|sed -n '/window.google.ac.h/{s/\\u003cb\\u003e//g;s/\\u003c\\\/b\\u003e//g;/'"$x"'/p;}' \
|cut -d\" -f4,6,8,10,12,14,16,18,20,22 \
|tr \" '\n'
#usage: echo query|$0
These options may soon disappear, like the www cache and other www search options before them. But "ifl" has been around since the early 90's, just look at the old
school HTML1. Not to be confused with searching for "answers" to questions
Here is an excerpt from rewrite.lua that reformats the IFL page from a 302 redirect to a "one blue link" SERP
if host=="www.google.com" then
applet:set_status(200)
body = string.gsub(body,"302 Moved","")
body = string.gsub(body,"The document has moved","")
body = string.gsub(body,"<A.HREF=\"https://www.google.com/url%?q=","")
body = string.gsub(body,"\">here</A>.\r","")
body = string.gsub(body,"https://[^<\r\n]+","1. <a href=%1>%1</a>")
body = string.gsub(body,"http://[^<\r\n]+","1. <a href=%1>%1</a>")
end #usage: echo query|$0
read x
xx=$(echo $x|tr '\40' +);
printf 'GET %s HTTP/1.0\r\nHost: %s\r\n\r\n' \
'/complete/search?client=heirloom-hp&hl=en&gs_rn=35&gs_ri=heirloom-hp&cp=3&gs_id=7&q='${xx}'&gs_gbg=' \
'clients1.google.com' \
|bssl client -connect 192.178.155.102:443 \
|sed -n '/window.google.ac.h/{
s/\"[a-z]*\"://g;
s/\\u003c[a-z]*\\u003e//g;
s/\\u003c\\\/[a-z]*\\u003e//g;
/'"$x"'/p;}' \
|cut -d\" -f4,6,8,10,12,14,16,18,20,22 \
|tr \" '\n'