web_search_helper.site module
Put the engine into a website folder, run it locally, check it online.
install copies search.php, web-search.js (and its .d.ts) and the
index files into a site folder, under search-data/ with a .htaccess
that denies everything. The index files do not need it (requested by URL,
they answer 404), but two locks are better than one.
check_online is to run AFTER uploading: it fetches the index files the way
a visitor would and fails if any byte of the corpus comes back; it then asks
the endpoint one question. An upload fails silently (a client that skips
dotfiles, a file left halfway); the page still displays.
- web_search_helper.site.bench(index, runs=5, question='test question', php='php')[source]
Time the PHP engine on an index: load, then full searches (words + meaning).
The search is exhaustive (every window is compared with the question).
ann-routerwould pick HNSW from 1 000 vectors under a 10 ms budget, but its thresholds are measured on numpy, not PHP, and the “I cannot answer” rule judges the ABSOLUTE best cosine, which an approximate index may miss. So the exhaustive scan stays as long as this measure fits the budget.
- web_search_helper.site.check_online(base_url, langs, question='test', data_dir='search-data')[source]
Is the corpus private, and does the endpoint answer?