Show HN: PageFish search algorithm
github.com
github.com
I like the idea of using unicode characters -- have you performance tested it to see if it gives superior performance to an ASCII filename of the same number of bytes?
Unicode seems great, but I noticed that filenames are restricted on various platforms, including Github. Uppercase and lowercase URLs are equivalent. So perhaps I should consider a different subset of characters instead of the first 65536 Unicode characters.
Performance is much faster than grep, because it only reads a fraction of the file. I couldn't find a good benchmark for ElasticSearch/Lucene/Sphinx, and apparently there isn't an easy way to compare.
https://stackoverflow.com/questions/44846271/performance-com...
In terms of performance I was more wondering whether or not "£" (one code point, two bytes) was much less expensive than "Ao" (two code points, two bytes). Just restricting yourself to ASCII might also have advantages for ensuring portability.
https://qntm.org/safe might also be of interest: discusses potential issues with using unicode as a high-density encoding -- base-2048 is Twitter-safe.
Also, apparently the files are not sorted by name (or I failed to see it). Searching in a sorted file using binary search is logarithmic, much faster than grepping which is linear.
Sorting can be done once, when the files are formed. BTW inserting into a sorted file should also be pretty fast (cheaper than appending and re-sorting).
When there's two elements with the same name (e.g. Geneva), the first result is the most common (the city I was born, not the town in the US).
This is a reasonable heuristic. OTOH when a page spins up fans in your laptop, or, worse, makes your browser unresponsive due to the amount of JavaScript executed, it's not as free as many users would like.
(I'm talking about the general principle, not the particular implementation.)
Imho, there is no point in such a custom solution: it is too limited and too simplified for real general uses.
Especially when it comes to actually working correctly.
As the author states where are some caveats with invalid "hashes" and i managed to get false negatives on the third try.
For example 'Baden-Württemberg' and 'Egypt' is in the file but not found by the search.
Not to mention fuzzy search which is highly important if you are doing any kind of text search.
And setting up some PostgresSQL or SQLite costs nothing compared to the cost of debugging this rather naive approach.
A better hashing/binning algorithm should fix that.
I don't think this can compete with a database for features. It's more a proof of concept for using the filesystem as a search index, which might have some other applications when server-side isn't available (e.g. IPFS).
Assign IP ranges to 255 servers or VMs, and hash to base 255 (not 65536 like this example).
Then let the router do the search.
It's really hard to type Chinese. But that means there's no typos in the query! Therefore fuzzy searching isn't as important.