News for hackers. Stuff that matters.
Re:Writing a full-text search engine using Bloom filters by zxcvgm on Tuesday December 24, 2013 @08:38AM (#6959295)
I have not yet had the chance to try it out but the acrylamid static blog generator written in Python ships with its own JS search [0] using compressed suffix trees. It's probably inspired by Sphinx, the Python doc generator, which has a similar feature [1].

For static blogs, I think this could be used as a first level of search, instead of directly going to Google first.

[0] http://posativ.org/acrylamid/static-search.html

[1] http://stackoverflow.com/questions/605888/whats-the-search-e...

Re:Writing a full-text search engine using Bloom filters by stormbrew on Tuesday December 24, 2013 @04:56AM (#6958889)
An alternative, but related, approach that would eliminate false positives could be to do an N-ary tree instead, where the bloom filter in this solution is just the first level of the tree. You could then download a json document for the child of the matching top level element to narrow it down to specific documents. You could also calculate relevancies this way.
Re:Writing a full-text search engine using Bloom filters by ris on Tuesday December 24, 2013 @01:59PM (#6960626)
I'm wondering why not build a tree of bloom filters with a bit array at each level being the bitwise OR of its child nodes. Hashing only needs be done once, and a comparison happens at each level of the tree, which can be traversed to easily find matches whilst discarding branches that are certain to be fruitless.

A bit of googling shows me this already exists and is called a bloofi tree.

Re:Writing a full-text search engine using Bloom filters by yxhuvud on Wednesday December 25, 2013 @04:44AM (#6962702)
Then you are better at googling than I am. Can I enquire for a link?

Edit: nm, it appeared when I searched for bloom trees instead of bloofi

Re:Writing a full-text search engine using Bloom filters by code_duck on Tuesday December 24, 2013 @05:57AM (#6958993)
This is probably an improvement over the simplest idea I can think of:

    <?php exec("grep $terms *html", $results);
Re:Writing a full-text search engine using Bloom filters by alcari on Tuesday December 24, 2013 @06:47AM (#6959084)
Any method that doesn't open you up to remote code execution exploits is an improvement over that.
Re:Writing a full-text search engine using Bloom filters by code_duck on Tuesday December 24, 2013 @11:55AM (#6960099)
Leveraging grep was my point, not that this would actually be code I'd use. Let's assume the line before that was getting $terms out of the query and sanitizing it. I suppose that doubles the length of my solution, though!
Re:Writing a full-text search engine using Bloom filters by jrockway on Tuesday December 24, 2013 @08:04PM (#6961791)
Ah yes, php_real_escape_grep_parameters(3).
Re:Writing a full-text search engine using Bloom filters by code_duck on Wednesday December 25, 2013 @11:20PM (#6965248)
Filtering out all characters other than ASCII alphabetical with preg_replace would probably do it.

And yeah, I'm not a huge fan of php - or the ridiculous function names it is known for. However, it can be dead simple to set up for trivial tasks (which is about all od want to use it for).

Re:Writing a full-text search engine using Bloom filters by StavrosK on Tuesday December 24, 2013 @06:21AM (#6959034)
Static site means never having to say "PHP"!
Re:Writing a full-text search engine using Bloom filters by deckiedan on Tuesday December 24, 2013 @07:06AM (#6959112)
True, but given how easy and prevenant PHP is on hosting sites, why not use a very small amount, just one or two php pages, each 200 lines or less, and everything else static?

Probably CGI would be better, mind you, keep everything static except what is obviously not.

Re:Writing a full-text search engine using Bloom filters by StavrosK on Tuesday December 24, 2013 @07:48AM (#6959193)
Because the line one draws is "no server-side code at all". If you use a bit of code for that, you might as well use a bit for this, and for the other thing, and soon it's a CMS.

Besides, the hosts I want to deploy on don't have PHP (S3, stock nginx, Github pages).

Re:Writing a full-text search engine using Bloom filters by deckiedan on Tuesday December 24, 2013 @08:07AM (#6959241)
Fair enough.

I switched our team's website to a completely static site a few years ago, they were using joomla (vomit) for essentially a broucher site that changed once a quarter.

I wonder if there would be a place for a 'json search as a service' thing - where you could upload your static content (as markdown, rst, txt, whatever) and then use their servers for full text queries which return a json list of matching page URLs and titles...

Re:Writing a full-text search engine using Bloom filters by rakoo on Tuesday December 24, 2013 @09:37AM (#6959481)
Because "no server-side code" means "I can host it completely on a CDN", which pretty much solves the scalability needs. If you need to scale those few lines of php or whatever language, this is gonna be much more difficult.

Plus, you can host it on different platforms such as freenet, gnunet, and have the simplest backup ever (`cp` is enough for having a functioning version on any OS of any kind).

Re:Writing a full-text search engine using Bloom filters by stormbrew on Tuesday December 24, 2013 @09:11AM (#6959375)
CGI is pretty much never better.
Re:Writing a full-text search engine using Bloom filters by al2o3cr on Tuesday December 24, 2013 @11:07AM (#6959856)
The motto of PHP devs is apparently "FKIN ESCAPING, HOW DOES IT WORK?". Use escapeshellarg, kids.
Re:Writing a full-text search engine using Bloom filters by code_duck on Tuesday December 24, 2013 @11:52AM (#6960086)
I didn't intend for this to represent the entire code for the search function. I've never written a php page that did something unsafe with user input. After all, '$terms' is not not $_GET['terms'] in my silly example. It's not defined.
Re:Writing a full-text search engine using Bloom filters by mcguire on Tuesday December 24, 2013 @01:36PM (#6960538)
escapeshellarg misses some cases. You need to use escapeshellarg_fixed.
Re:Writing a full-text search engine using Bloom filters by jrockway on Tuesday December 24, 2013 @08:05PM (#6961796)
real_escapeshellarg_fixed, you mean.
Re:Writing a full-text search engine using Bloom filters by deckiedan on Tuesday December 24, 2013 @07:21AM (#6959149)
Nice idea :-)

I once wrote a python library for wrapping static content into a sqlite database for full text searching, for roughly the same use-case (static content, but I would like a search system). I just threw it online, if anyone is interested.

https://github.com/danthedeckie/pagestore

Re:Writing a full-text search engine using Bloom filters by posativ on Tuesday December 24, 2013 @06:56PM (#6961630)
You are not doing full-text search with bloom filters (unless you add all partial words to the filter), only word-search, which is imho the biggest disadvantage (e.g. typos in the index or on the client's side).
Re:Writing a full-text search engine using Bloom filters by vdm on Tuesday December 24, 2013 @02:05PM (#6960656)
This reminds me of how Datomic clients download read-only segments and process queries locally. http://docs.datomic.com/architecture.html